Re: See if this makes any sense
| From: | Brad Bonkoski | Date: | Thu, 05 Oct 2006 19:35:57 +0000 |
| Subject: | Re: See if this makes any sense | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242708@lists.php.net to get a copy of this message | ||
Deckard wrote:
Hi, I've burned my brain, checked other sites and come to a code that works. I ask you, please, to see if this makes any sense and/or can be improved. I'd really appreciate. Warm Regads, Deckard dbInsert.php: ------------------------------------------------------------------- <?php /* * class to make inserts * */ // includes include_once('/var/www/html/config.inc.php'); include_once('adodb/adodb.inc.php'); class dBInsert { // global variables var $table; var $sql; // constructor function dBInsert($table, $sql) { $this->table = $table; $this->sql = $sql; return(TRUE); } // function that constructs the sql and inserts it into the database function InsertDB($table, $sql) {#2. You don't even us the $table param. Otherwise, not sure what this buys you...print($sql); // connect to MySQL $conn = &ADONewConnection('mysql');$conn->debug=1;$conn->PConnect('localhost', 'gamito', 'ble', 'wordlife');// execute the insert if ($conn->Execute($sql) === false) print 'error inserting: '.$conn->ErrorMsg().'<BR>'; return (TRUE); } } ?> ------------------------------------------------------ testedb.php ------------------------------------------------------ <?php include_once("classes/dBInsert.php"); $sql = "INSERT INTO wl_admins VALUES ('',3)"; $dBInsert = new dBInsert('wl_admins', $sql); $dBInsert->InsertDB('wl_admins', $sql); ?> ------------------------------------------------------ #1. If $table and $sql are class variables, why are you passing them as params to the InsertDB method?