PHPPDO-& amp; gt; exec (): execute an SQL statement that does not return a result set. Does PHPPDO-exec () execute an SQL statement that does not return a result set? The php * DO-exec () method is mainly used for operations that DO not return result sets, such as INSERT, UPDATE, DELETE, and other operations. it returns php pdo-> exec () execute an SQL statement that does not return a result set
The exec () method is mainly used for operations that do not return result sets, such as INSERT, UPDATE, DELETE, and so on. The Returned result is the number of columns affected by the current operation syntax: PDO-> exec (string statement) * // Construct the PDO connection header ("Content-type: text/html; charset = utf-8"); $ dbh = "mysql: host = localhost; dbname = test "; $ db = new PDO ($ dbh, 'root', '123 '); $ db-> query ("set character set 'utf8'"); // write data $ username = "liming"; $ password = md5 ("123456 "); $ regdate = time (); // The Returned result is an integer. Therefore, the following statement can contain no quotation marks $ SQL _exec = "INSER T into userlist (username, password, regdate) VALUES ('$ username',' $ password', $ regdate) "; $ count = $ db-> exec ($ SQL _exec ); echo 'write '. $ count. 'data record! '; Echo"
"; $ SQL _select =" SELECT * FROM userlist "; $…… = $ db-> query ($ SQL _select ); // $ something is the result set object // $ TH-> setFetchMode (PDO: FETCH_ASSOC); // if the returned result type is not specified in setFetchMode, you can also use the fetch () method to set while ($ row = $ Something-> fetch (PDO: FETCH_ASSOC) {print_r ($ row); echo "username :". $ row ['username']. ""; echo "password :". $ row ['password']. ""; echo "registration time :". date ("Y-m-d", $ row ['regdate']). "" ;}?>
The http://www.bkjia.com/PHPjc/1072631.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1072631.htmlTechArticlePHP PDO-exec () executes the SQL statement without returning the result set? Php/* DO-exec () method is mainly used for operations that DO not return result sets, such as INSERT, UPDATE, DELETE, etc. it returns...