The difference between PHP Pdostatement object Bindpram (), Bindvalue (), and Bindcolumn
Pdostatement::bindparam― binds a parameter to the specified variable name.
Binds a PHP variable to the corresponding named placeholder or question mark placeholder in the SQL statement used as a preprocessing. Unlike Pdostatement::bindvalue (), this variable is bound as a reference and only takes its value when Pdostatement::execute () is called.
Pdostatement::bindvalue― binds a value to a parameter.
Binds a value to the corresponding named placeholder or question mark placeholder in the SQL statement that is used as a preprocessing.
Prepare ("SELECT * from users where user =: User"); $user = "Jack";//Correct $stm->bindparam (": User", $user);//Error $stm-> Bindparam (": User", "Jack");//Correct $stm->bindvalue (": User", $user);//Correct $stm->bindvalue (": User", "Jack"); So using Bindparam is the second argument that can be used only with the variable name, not the variable value, and Bindvalue to the use of a specific value.?>
Pdostatement::bindcolumn― binds a column to a PHP variable.
Schedules a specific variable to be bound to a given column in a query result set. Each call to Pdostatement::fetch () or Pdostatement::fetchall () updates all variables bound to the column.
Prepare ($sql); $stmt, execute (); /* Bind by column number * /$stmt bindcolumn (1, $name); $stmt-Bindcolumn (2, $colour); /* Bind by column name * /$stmt-bindcolumn (' calories ', $cals); while ($row = $stmt Fetch (PDO:: Fetch_bound)) { $data = $name . " \ t " . $colour . " \ t " . $cals . " \ n "; Print $data; } } catch (Pdoexception $e) { print $e-getMessage ();} } ReadData ($DBH);? >
Reference Source:
The difference between PHP Pdostatement object Bindpram (), Bindvalue (), and Bindcolumn
Http://www.lai18.com/content/369335.html
Extended Reading
"PHP Database PDO series" series of technical Articles to organize the collection
1php Database Abstraction Layer PDO
2php Database Abstraction Layer PDO introduction and simple example
3PHP PDO class resolves database connectivity issues
4PHP 5 Data Object (PDO) abstraction layer with Oracle
5PHP Pdostatement:bindparam Insert Data error problem analysis
6PDO Anti-injection principle analysis and considerations for using PDO summary
7PHP Database Abstraction Layer PDO (a)?? Introduction and Installation Configuration
8PHP Database Abstraction Layer PDO (v)?? Error and error handling
9PHP Database Abstraction Layer PDO (iii)?? Transactions and Auto-commit
10PHP Database Abstraction Layer PDO (ii)?? Connection and connection management
11PHP Database Abstraction Layer PDO (four)?? Preprocessing statements and stored procedures
12PHP Database Abstraction Layer PDO (vii)?? Related classes and methods
13PHP Database Abstraction Layer PDO (vi)?? Large Object (lobs)
14PHP PDO Operation Summary
15PHP pdostatement The difference between Bindpram (), Bindvalue (), and Bindcolumn
16PDO preprocessing statement Pdostatement Object Usage Summary
Usage and difference of MySQL, mysqli and PDO in 17PHP "original"
18PHP MySQL database operation class for PDO
19php using PDO connection Error connection failed SQLSTATE solution
20php How to connect and query SQL database using PDO
21php connecting the MSSQL Server DB instance with PDO
22php using PDO method
Example of MySQL transaction usage for PDO under 23php
24php using PDO to operate a MySQL DB instance
25PHP PDO Fetch mode output list of various parameters
26 a summary of some knowledge about PHP PDO
Database connection mode in 27php comparison of PDO and mysqli
28PDO Anti-injection principle analysis and precautions
29php MySQL Connection method PDO use detailed
30PHP using PDO to connect to an Access database
31php the PDO way realizes the database to delete and change to investigate
32 on the ROWCOUNT function of PDO