mysqli

Database abstraction layer ontop of mysqli

故事扮演 提交于 2020-12-13 07:20:17
问题 when trying to build robust database code (table locking, transactions, etc) i am always annoyed by the mass of code that needs to be done. For example a transaction out of two prepared statements where i want to delete a user and update something about him in an "actions" table: Lock Table users, actions Start a transaction (autocommit false) Make a prepared statement for the deletion of a user Check if statement is != false (cause it could have already failed at 3. Bind param Check

How can I use mysqli fetch_assoc() several times with prepared statements on same PHP page?

半世苍凉 提交于 2020-12-12 06:11:11
问题 Is there a way to enable the use of fetch_assoc() several times on the same page with prepared statements? $data = $conn->prepare("SELECT * FROM some_table WHERE id=?"); $data->bind_param('i',$id); $data->execute(); $result = $data->get_result(); I'd like to be able to use fetch_assoc() on the same page as many times as I want as many different ways I want. If I want to loop twice, I should be able to do that. If I want to loop and do a single fetch, I should also be able to do that. Right

How can I use mysqli fetch_assoc() several times with prepared statements on same PHP page?

左心房为你撑大大i 提交于 2020-12-12 06:10:28
问题 Is there a way to enable the use of fetch_assoc() several times on the same page with prepared statements? $data = $conn->prepare("SELECT * FROM some_table WHERE id=?"); $data->bind_param('i',$id); $data->execute(); $result = $data->get_result(); I'd like to be able to use fetch_assoc() on the same page as many times as I want as many different ways I want. If I want to loop twice, I should be able to do that. If I want to loop and do a single fetch, I should also be able to do that. Right

What is the difference between mysqli::real_connect and new mysqli object in connecting database?

我只是一个虾纸丫 提交于 2020-12-08 07:14:49
问题 I'm using this method to connect to mysql db : $this->_Con = new mysqli($this->_DB['Server'],$this->_DB['User'],$this->_DB['Pass'],$this->_DB['DB']); What is the difference when I connect using this method: $this->_Con = mysqli_init(); $this->_Con->real_connect($this->_DB['Server'],$this->_DB['User'],$this->_DB['Pass'],$this->_DB['DB']); 回答1: Its just another way of connecting to your database. If you use mysqli_init() it will initialize the mysqli object first. Then using the object you will

What is the difference between mysqli::real_connect and new mysqli object in connecting database?

白昼怎懂夜的黑 提交于 2020-12-08 07:14:28
问题 I'm using this method to connect to mysql db : $this->_Con = new mysqli($this->_DB['Server'],$this->_DB['User'],$this->_DB['Pass'],$this->_DB['DB']); What is the difference when I connect using this method: $this->_Con = mysqli_init(); $this->_Con->real_connect($this->_DB['Server'],$this->_DB['User'],$this->_DB['Pass'],$this->_DB['DB']); 回答1: Its just another way of connecting to your database. If you use mysqli_init() it will initialize the mysqli object first. Then using the object you will

How do I enable mysqli for my PHP script? [duplicate]

北战南征 提交于 2020-12-05 11:54:26
问题 This question already has answers here : How to install MySQLi on MacOS (16 answers) Closed 9 months ago . I am trying to use mysqli to connect to my MySQL database using mysqli_connect(). However, whenever I grab a reference to my .php file that attempts to connect to the database, it throws a fatal error: Fatal error: Uncaught Error: Call to undefined function mysqli_connect() I read that you must delete a semi-colon from php.ini, but my PHP7 folder does not contain a strictly php.ini file.

Couldn't fetch Mysqli_result

被刻印的时光 ゝ 提交于 2020-11-29 04:44:05
问题 I've got this error Warning : mysqli_fetch_array() [function.mysqli-fetch-array]: Couldn't fetch mysqli_result in /home/fights7/public_html/include/load_more_home_posts.php on line 12 And would like to know what I've done wrong with the below code? $articles_data = mysqli_query($mysqli,"SELECT * FROM streamdata WHERE streamitem_id < '$lastID' ORDER BY streamitem_id DESC LIMIT 10") or die(mysql_error()); while($articles_info = mysqli_fetch_array($articles_data)) { $json = array(); $json[

Couldn't fetch Mysqli_result

懵懂的女人 提交于 2020-11-29 04:42:47
问题 I've got this error Warning : mysqli_fetch_array() [function.mysqli-fetch-array]: Couldn't fetch mysqli_result in /home/fights7/public_html/include/load_more_home_posts.php on line 12 And would like to know what I've done wrong with the below code? $articles_data = mysqli_query($mysqli,"SELECT * FROM streamdata WHERE streamitem_id < '$lastID' ORDER BY streamitem_id DESC LIMIT 10") or die(mysql_error()); while($articles_info = mysqli_fetch_array($articles_data)) { $json = array(); $json[