<?php include_once "./config.inc.php"; include_once INCLUDE_PATH . "connection.php"; include_once "./cls_classproduct.php"; echo "Step 1"; //we call here the class with NO ID //will be done //SELECT * FROM table WHERE id=''; $prod = new classProduct("0"); //Here we write this values into the database //but because no ID was given, will be INSERT a new line. $prod->setItem("Item A"); $prod->setItemId("item_b"); $prod->setVotes("10"); // this line will call the save from the class $prod->save(); // END STEP 1 echo "Step 2"; //we call here the class with ID 2 //will be done //SELECT * FROM table WHERE id='2'; //$prod=new classProduct("2"); //Here we write this values into the database //because ID was given, will be UPDATE ID 2. /* $prod->setItem("Item A"); $prod->setItemId("item_c"); $prod->setVotes("10"); // this line will call the save from the class $prod->save();
$prod->setItemId("item_a"); $prod->setVotes("10"); $prod->save(); $prod = new classProduct(0); $prod->setItem("Item B"); $prod->setItemId("item_b"); $prod->setVotes("20"); $prod->save(); $prod = new classProduct(0); $prod->setItem("Item C"); $prod->setItemId("item_c"); $prod->setVotes("30"); $prod->save(); $prod = new classProduct(0); $prod->setItem("Item D"); $prod->setItemId("item_d"); $prod->setVotes("40"); $prod->save(); $prod->debug_print_history(); exit; $prod = new classProduct(11); $prod = new classProduct('WHERE `votes`="10"'); $prod->setItem("Item C"); $prod->setItemId("item_c"); $prod->setVotes("60"); $prod->save(); print_r($prod); mysql_close($link); ?>