From: <cod...@go...> - 2009-05-26 17:50:08
|
Author: ke...@se... Date: Tue May 26 10:49:33 2009 New Revision: 1360 Modified: trunk/andro/lib/androX6.php Log: Allow PHP-level hooks before and after insert and update. In your x6 class file for table "customers" (for example), make any of the four methods customers_before_insert, customers_after_insert, customers_before_update, customers_after_update. All four take this form: function customers_before_insert($row) { row['column'] = 'value....'; return $row; } Where the routine accepts the row, modifies it, and returns it. Fixes issue 23 Status: Verified Modified: trunk/andro/lib/androX6.php ============================================================================== --- trunk/andro/lib/androX6.php (original) +++ trunk/andro/lib/androX6.php Tue May 26 10:49:33 2009 @@ -205,21 +205,41 @@ if($errors) return; if(!isset($row['skey'])) { + # KFD 5/26/09 Google Feature #23, hook inserts + $method = $table_id."_before_insert"; + if(method_exists($this,$method)) { + $row = $this->$method($row); + } $skey = SQLX_Insert($dd,$row); if(!errors()) { $row=SQL_OneRow( "Select * FROM {$dd['viewname']} WHERE skey = $skey" ); + # KFD 5/26/09 Google Feature #23, hook inserts + $method = $table_id."_after_insert"; + if(method_exists($this,$method)) { + $row = $this->$method($row); + } } x6Data('row',$row); } else { + # KFD 5/26/09 Google Feature #23, hook updates + $method = $table_id."_before_update"; + if(method_exists($this,$method)) { + $row = $this->$method($row); + } SQLX_Update($dd,$row); if(!errors()) { $skey = $row['skey']; $row=SQL_OneRow( "Select * FROM {$dd['viewname']} WHERE skey = $skey" ); + # KFD 5/26/09 Google Feature #23, hook updates + $method = $table_id."_after_update"; + if(method_exists($this,$method)) { + $row = $this->$method($row); + } x6Data('row',$row); } } |