I need to edit some PHP that wasn't written by me, I've gotten most of it done but there's a bit I can't figure out the correct syntax for.
Basically we grab data from a Google Fusion Table and populate a table with it, once we've edited the data in the table we can update that information to a production version of the same table. One of the update queries looks like this:
if($table_row[12]=="New"){
$tableid1 = '1bsSleKDBdkhQZfn-oADx0tUtoOc32RqIyiX05Bo';
$insertresults = $ftclient->query(SQLBuilder::insert($tableid1,
array('SUBURB'=> $table_row[1],
'ROAD_NAME' => $table_row[2],
'DESCRIPTION' => $table_row[3],
'DIRECTION' => $table_row[4],
'STATUS' => $table_row[5],
'SITE_ID' => $table_row[6],
'COMMON_NAME' => $table_row[7],
'Lat' => $table_row[8],
'Long' => $table_row[9],
'OPERATING_DAY' => $table_row[10],
'OPERATING_HOURS' => $table_row[11],
'Version' => "current")));
$insertresults = explode("\n", $insertresults);
$rowid1 = $insertresults[1];
$updateresults = $ftclient->query(SQLBuilder::update($tableid,
array('SUBURB'=> $table_row[1],
'ROAD_NAME' => $table_row[2],
'DESCRIPTION' => $table_row[3],
'DIRECTION' => $table_row[4],
'STATUS' => $table_row[5],
'SITE_ID' => $table_row[6],
'COMMON_NAME' => $table_row[7],
'Lat' => $table_row[8],
'Long' => $table_row[9],
'OPERATING_DAY' => $table_row[10],
'OPERATING_HOURS' => $table_row[11],
'Version' => "current",
'Edited_By' => $table_row[13],
'Date_Edited' => $table_row[14]),$table_row[0]));
$updateresults = explode("\n", $updateresults);
$rowid2 = $updateresults[1];
}
What I need to do is write a similar type of SQLBuilder query that will update every record with the same SITE_ID when SUBURB is changed in one of them (i.e., if a record has SUBURB Sydney, SITE_ID 1, each record with SITE_ID 1 must be changed if one record's SUBURB value is changed from Sydney to Melbourne). Not sure exactly how to phrase this syntactically or how I would go about writing the query using SQLBuilder. Any helpw would be appreciated!
SQLBuilder is obviously a locally included class. You will need to look at its documentation or the update method itself in order to see how it expects a where clause to be coded.
The SQL for this would be:
If you are able to run pure SQL then that will do it. Otherwise I'd need to see the Class libraries.