I don't understand what does this code line do, $this->link->query($query)?
本问题已经有最佳答案,请猛点这里访问。
只有$this->link->query($query)这部分我知道link是类数据库的成员变量,但不知道$this->link->query($query)执行时会发生什么?救命,我是个编程新手
我的全部代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <?php class Database { public $db_host=DB_HOST; public $db_user=DB_USER; public $db_pass=DB_PASS; public $db_name=DB_NAME; public $link; public $error; public function __construct() { // Call connect function $this->connect(); } private function connect() { $this->link= new mysqli($this->db_host,$this->db_user,$this->db_pass,$this->db_name); if(!$this->link) { $this->error="Connection Failed"; return false; } } public function select($query) { $result=$this->link->query($query) or die ("Query could not execute"); } } ?> |
1 | $result = $this->link->query("SELECT * FROM table WHERE 1") ; |
在调用mysqli
1 2 | $sql ="SELECT * FROM table WHERE 1" ; $result = $this->link->query($sql) ; |
在您的代码中,包含SQL字符串的变量称为
所以你叫