$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); ?>
//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(); */ // END STEP 2 echo "Step 3 - BUG, ca face un insert nou, nu update si daca nu exista, ar trebui sa exit, nu sa executre mai departe cu ID()"; //we call here the class with ID 2 //will be done //SELECT * FROM table WHERE id='2'; $prod = new classProduct("WHERE `votes`='10' AND `itemid`='item_b'"); //Here we write this values into the database //because ID was given, will be UPDATE ID 2. $prod->setVotes("100"); // this line will call the save from the class $prod->save(); //$prod=new classProduct('WHERE `votes`="2"'); // You can delete like this //$prod->delete(" WHERE `id` < '1150'"); // You can call UNDO command. //$prod->undo(); // Nu stiu ce e //$prod->debug_print_history(); //print($prod->undo()); mysql_close($cid);
<?php include_once "./cls_classproduct.php"; $link = mysql_connect("localhost", "root", "123456"); if (!$link) { die("Could not connect to the database"); } if (!mysql_select_db("test", $link)) { die("Could not use the database"); } //$prod=new classProduct(0); $prod = new classProduct('WHERE `votes`="10"'); //$prod->undo(237); //$prod->debug_print_history(); //$prod->setItem("Item A3"); //$prod->setItemId("item_b3"); //$prod->setVotes("10000"); //$prod->save(); //$prod->delete(" WHERE `id` > '0'"); //$prod->undo(); //// $prod->debug_print_history(); //$prod->delete("WHERE id<96"); //$prod->debug_print_history(); //$prod->undo(); //print($prod->undo()); mysql_close($link); ?>