图书类程序设计初始化文件
May 25, 2016 pm 05:15 PMphp代码
<!--图书类文件: class_book.php--> <?php class book { private $id; private $name; private $price; private $author; function __construct() //__construct:构造函数,建立连接 { //$this->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() //添加书目 { $db=new database(); $query="INSERT INTO Computer (name,price,author) "; $query.="VALUES ('$this->name',$this->price,'$this->author')"; $db->execute($query); $db=null; } function update() //修改书目 { $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() //删除书目 { $db=new database(); $query="DELETE FROM Computer WHERE id=$this->id"; $db->execute($query); $db=null; } static function query($condition) //查询书目 { 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语言",15.20,"吴强"); $b->add(); //$b->__set(new_author,"3"); //$b->update(); //$b->delete(); //*/ ?>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
