DB autoPrepare: can you use a variable to determine if you use DB_AUTOQUERY_UPDATE or DB_AUTOQUERY_INSERT ?

From: Date: Thu, 04 Aug 2005 15:45:46 +0000
Subject: DB autoPrepare: can you use a variable to determine if you use DB_AUTOQUERY_UPDATE or DB_AUTOQUERY_INSERT ?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20270@lists.php.net to get a copy of this message
Below is the basic code I'll be using. Depending on the user action, it will either be an INSERT or UPDATE. ANd depedning on what rights the user has, it will determine what fields that user can use. I want to cut down on code so I have tried to parameterize all the fields I can. When I try to use DB_AUTOQUERY_UPDATE in parameter form, it does not work. The fieldlist below has been left out on purpose. Any ideas? code below ========================================== $table_name = 'table1'; if (edit == true) { $how = 'DB_AUTOQUERY_UPDATE'; $where = 'ID = '.$values['ID']; if ($_SESSION['']['user']=="Admin") { $table_fields = array(<fieldlist>); $table_values = array(<values list>); } else { $table_fields = array(<fieldlist>); $table_values = array(<values list>); } $sth = $db->autoPrepare($table_name, $table_fields, $process_how, $process_where); } else { $process_how = 'DB_AUTOQUERY_INSERT'; if ($_SESSION['']['user']=="Admin") { $table_fields = array(<fieldlist>); $table_values = array(<values list>); } else { $table_fields = array(<fieldlist>); $table_values = array(<values list>); } $sth = $db->autoPrepare($table_name, $table_fields, $process_how); } if (PEAR::isError($sth)) { die($sth->getMessage()); } $res =& $db->execute($sth, $table_values); if (PEAR::isError($res)) { die($res->getMessage()); } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

« previous php.pear.general (#20270) next »