How to Update Multiple Table while using View/Custom View

Tips submitted by PHPMaker users

How to Update Multiple Table while using View/Custom View

Postby Bishu » Fri Aug 23, 2013 8:41 pm

I have found so many thread that are discussing about multiple table update while using View/Custom View.
i wrote a small function to update my view and custom view

$tablearray=array('table1','table2','table3',.........);
$rsnew is the array in the *Row_Updating* Server Event (see Server Events and Client Scripts in the help file)
$where is the where clause of the sql to update to a particular record only.

function my_MulitUpdate($tablearray, $rsnew, $where){
foreach($tablearray as $table){
$rsnew1 = array();
$table1 = ew_Execute("SELECT COLUMN_NAME FROM information_schema.columns WHERE table_name = '".$table."'");
while(!$table1->EOF){
$column = $table1->fields('COLUMN_NAME');
if(array_key_exists($column,$rsnew)){
$rsnew1[$column] = $rsnew[$column];
}
$table1->MoveNext();
}
$table1->close();
$classname = "c".$table;
$updatetable = new $classname();
$updatetable->update($rsnew1,$where);
}
}

The one disadvantage of this function is we have to generate the table code once while generating the project. otherwise the code
$updatetable = new $classname(); will get an error.

Any suggestion will be highly appreciated.
Bishu
 
Posts: 192
Joined: Fri Jan 18, 2013 2:12 am

Re: How to Update Multiple Table while using View/Custom Vie

Postby harvest316b » Sat Nov 19, 2016 3:44 pm

Try Database Triggers?
harvest316b
 
Posts: 16
Joined: Sat Nov 12, 2016 1:45 pm


Return to User Submitted Tips (PHPMaker)