Location: PHPKode > scripts > Data Objects > sample.php

Setting fetch mode for ADODB for further information about this read the ADODB documentation
define('ADODB_ASSOC_CASE', 2); # use native-case for ADODB_FETCH_ASSOC


$database = &ADONewConnection('mysql');
$database->Connect('localhost', 'root', '', 'catalogo'); # connect to DB

$table = new dataObject($database, "producto"); // Opens the table called producto

$table->load(2);  // If the PK is a single field index just send the Id
//$table->load(array("id"=>2, "client_id"=>1)); // If the PK is composed send the multiple fields as an array

$table->set('nombre', "Vino de cocox");
$table->set('cantidad', 6);
$table->set('valor', 14);

// If the product using the selected ID doesn't exists the register is inserted, else is updated

print $table->_error;  // If there is no error then nothing is printed.

Return current item: Data Objects