Library program design initialization file php code
Name = $ name; // $ this-> price = $ price; // $ this-> author = $ author;} function _ set ($ property_name, $ value) {return $ this-> $ property_name = $ value;} function _ get ($ property_name) {if (isset ($ this-> $ property_name )) {return $ this-> $ property_name;} else {return null;} function add () // add bibliography {$ db = new database (); $ query = "insert into Computer (name, price, author)"; $ query. = "VALUES ('$ this-> name', $ this-> price,' $ this-> author')"; $ d B-> execute ($ query); $ db = null;} function update () // modify the bibliography {$ db = new database (); $ query = "UPDATE Computer SET"; $ query. = "name = '$ this-> name', price = $ this-> price, author =' $ this-> author '"; $ query. = "WHERE id = $ this-> id"; $ db-> execute ($ query); $ db = null;} function delete () // DELETE the bibliography {$ db = new database (); $ query = "delete from Computer WHERE id = $ this-> id"; $ db-> execute ($ query ); $ db = null;} static function query ($ condition) // query the bibliography {if ($ Condition = "" | $ condition = null) $ condition = ""; else $ condition = "WHERE ". $ condition; $ db = new database (); $ query = "SELECT * FROM Computer ". $ condition; $ arr = $ db-> query ($ query); return $ arr; $ db = null ;}/ * $ B = new book ("C language ", 15.20, "Wu Qiang"); $ B-> add (); // $ B->__ set (new_author, "3 "); // $ B-> update (); // $ B-> delete (); // */?>