templemedia
Posts: 34
|
| Posted: 10/30/2007, 5:25 AM |
|
Hi All
I have created some custom code in the before build update event of an ediatbale grid to copy the contents of the grid to another database and table.
I have a problem with the code only getting multiple results for the first table column, the rest of the columns remian null and no results are inserted into the database.
Any ideas on where I am going wrong?
Custom code is shown below: -
I am using php 5, mysql 5 and IIS.
Regards
Richard
function schvis1_ds_BeforeBuildUpdate(& $sender)
{
$schvis1_ds_BeforeBuildUpdate = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $schvis1; //Compatibility
//End schvis1_ds_BeforeBuildUpdate
//Custom Code @42-2A29BDB7
// -------------------------
global $DFES_Number_ID_Insert;
global $School_Organisation_Insert;
global $District_Insert;
global $County_Insert;
global $Type_Insert;
global $Postcode_Insert;
global $Address_Insert;
global $Contact_Insert;
global $Tel_Code_Insert;
global $Tel_No_Insert;
global $Fax_No_Insert;
global $Website_Insert;
global $Email_Insert;
global $Age_Insert;
global $Notes_Insert;
$db = new clsDBConnection1();
//SQL = "DELETE FROM course_schedule WHERE Course_Ref=". $db2->ToSQL($Course_Reference, ccsText). "";
$SQL = "SELECT DfESNumber FROM schvis1";
$db->query($SQL);
$db->Debug = FALSE;
echo $SQL . "<br>";
//connect to slave database and delete all records
$db2 = new clsDBConnection2();
$SQL2 = "DELETE FROM schvis1 ";
$db2->query($SQL2);
$db2->Debug = FALSE;
echo $SQL2 . "<br>";
$db2->close();
while ($db->next_record()){
$Result = $db->next_record();
if ($Result){
$DFES_Number_ID_Insert = $db->f("DfESNumber");
$School_Organisation_Insert = $db->f("SCHOOL_ORGANISATION");
$District_Insert = $db->f("DISTRICT");
$Area_Insert = $db->f("AREA");
$County_Insert = $db->f("COUNTY");
$Type_Insert = $db->f("TYPE");
$Postcode_Insert = $db->f("POST_CODE");
$Nos_Of_Pupils_Insert = $db->f("NOSOFPUPILS");
$Address_Insert = $db->f("ADDRESS");
$Address2_Insert = $db->f("ADDRESS2");
$Contact_Insert = $db->f("CONTACT");
$Tel_Code_Insert = $db->f("TEL_CODE");
$Tel_No_Insert = $db->f("TEL_NO");
$Fax_No_Insert = $db->f("FAX_NO");
$Website_Insert = $db->f("WEBSITE");
$Officer_Giving_Talk_Insert = $db->f("OFFICERGIVINGTALK");
$Record_Entered_By_Insert = $db->f("Record_Entered_By");
$Record_Assigned_To_Insert = $db->f("Record_Assigned_To");
$Master_Last_Updated_Insert = $db->f("Master_Last_Updated");
$Slave_Last_Updated_Insert = $db->f("Slave_Last_Updated");
$Email_Insert = $db->f("EMAIL");
$Age_Insert = $db->f("AGE");
$Notes_Insert = $db->f("Notes");
}
// connect to slave and insert records
$db3 = new clsDBConnection2();
$SQL3 = "INSERT INTO schvis1 ("
. "DfESNumber, "
. "SCHOOL_ORGANISATION, "
. "DISTRICT, "
. "AREA, "
. "COUNTY, "
. "TYPE, "
. "POST_CODE, "
. "NOSOFPUPILS, "
. "ADDRESS, "
. "ADDRESS2, "
. "CONTACT, "
. "TEL_CODE, "
. "TEL_NO, "
. "FAX_NO, "
. "WEBSITE, "
. "OFFICERGIVINGTALK, "
. "Record_Entered_By, "
. "Record_Assigned_To, "
. "Master_Last_Updated, "
. "Slave_Last_Updated, "
. "EMAIL, "
. "AGE, "
. "Notes "
. ") VALUES ("
. $db->ToSQL($DFES_Number_ID_Insert, ccsInteger) . ", "
. $db->ToSQL($School_Organisation_Insert, ccsText) . ", "
. $db->ToSQL($District_Insert, ccsInteger) . ", "
. $db->ToSQL($Area_Insert, ccsInteger) . ", "
. $db->ToSQL($County_Insert, ccsText) . ", "
. $db->ToSQL($Type_Insert, ccsInteger) . ", "
. $db->ToSQL($Postcode_Insert, ccsText) . ", "
. $db->ToSQL($Nos_Of_Pupils_Insert, ccsInteger) . ", "
. $db->ToSQL($Address_Insert, ccsText) . ", "
. $db->ToSQL($Address2_Insert, ccsInteger) . ", "
. $db->ToSQL($Contact_Insert, ccsText) . ", "
. $db->ToSQL($Tel_Code_Insert, ccsInteger) . ", "
. $db->ToSQL($Tel_No_Insert, ccsInteger) . ", "
. $db->ToSQL($Fax_No_Insert, ccsInteger) . ", "
. $db->ToSQL($Website_Insert, ccsText) . ", "
. $db->ToSQL($Officer_Giving_Talk_Insert, ccsInteger) . ", "
. $db->ToSQL($Record_Entered_By_Insert, ccsInteger) . ", "
. $db->ToSQL($Record_Assigned_To_Insert, ccsInteger) . ", "
. $db->ToSQL($Master_Last_Updated_Insert, ccsInteger) . ", "
. $db->ToSQL($Slave_Last_Updated_Insert, ccsInteger) . ", "
. $db->ToSQL($Email_Insert, ccsText) . ", "
. $db->ToSQL($Age_Insert, ccsInteger) . ", "
. $db->ToSQL($Notes_Insert, ccsText) . ")";
$db3->query($SQL3);
$db3->Debug = FALSE;
echo $SQL3 . "<br>";
}
$db->close();
$db3->close();
|
 |
 |
templemedia
Posts: 34
|
| Posted: 10/30/2007, 5:31 AM |
|
Problem solved.
I was only selecting the first column from the table in the first db connection.
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 10/30/2007, 8:02 AM |
|
Good4U
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|