PHPPDOStatement object bindpram (), bindvalue (), and bindcolum

Source: Internet
Author: User
Tags mssql server php database
Differences between PHPPDOStatement objects bindpram (), bindvalue (), bindcolum PHP PDOStatement objects bindpram (), bindvalue (), and bindcolumn

PDOStatement: bindParam-bind a parameter to the specified variable name.

Bind a PHP variable to the corresponding name placeholder or question mark placeholder in the SQL statement used for preprocessing. Unlike PDOStatement: bindValue (), this variable is bound as a reference and takes its value only when PDOStatement: execute () is called.

PDOStatement: bindValue-binds a value to a parameter.

Bind a value to the corresponding name placeholder or question mark placeholder in the SQL statement used for 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"); // therefore, bindParam is the second parameter. only the variable name can be used, but not the variable value, bindValue can use specific values.?>


PDOStatement: bindColumn-bind a column to a PHP variable.

Bind a specific variable to a specified column in a query result set. Every call to PDOStatement: fetch () or PDOStatement: fetchAll () will update all the variables bound to the column.

 Prepare ($ SQL); $ stmt-> execute ();/* bind a column number */$ stmt-> bindColumn (1, $ name ); $ stmt-> bindColumn (2, $ color);/* bind by column name */$ stmt-> bindColumn ('calories ', $ cals ); while ($ row = $ stmt-> fetch (PDO: FETCH_BOUND) {$ data = $ name. "\ t ". $ color. "\ t ". $ cals. "\ n"; print $ data ;}} catch (PDOException $ e) {print $ e-> getMessage () ;}} readData ($ dbh);?>



Reference Source:
Differences between PHP PDOStatement objects bindpram (), bindvalue (), and bindcolumn
Http://www.lai18.com/content/369335.html

Additional reading

Collect and collect technical articles from the "PHP database PDO series" series

1php database abstraction layer PDO

Introduction to PDO in the abstraction layer of 2php databases and simple examples

3PHP PDO class solves database connection problems

4PHP 5 data object (PDO) abstraction layer and Oracle

5PHP PDOStatement: Analysis of bindParam data insertion errors

6PDO anti-injection principle analysis and precautions for using PDO

7PHP database abstraction layer PDO (1 )?? Introduction and installation configuration

PDO (5) in the abstract layer of the 8PHP database )?? Handle errors and errors

9PHP database abstraction layer PDO (3 )?? Transactions and automatic submission

10PHP database abstraction layer PDO (2 )?? Connection and connection management

PDO (4 )?? Pre-processing statements and stored procedures

12. PDO (7) in the abstraction layer of the PHP database )?? Related classes and methods

PDO (6) in the abstraction layer of the 13PHP database )?? Large Object (LOBs)

14PHP PDO operation summary

Differences between the 15PHP PDOStatement object bindpram (), bindvalue (), and bindcolumn

Summary of use of the 16PDO preprocessing statement PDOStatement object

Usage and difference of MySQL, MySQLi, and PDO in 17PHP [original]

Mysql database operations implemented by PDO in 18PHP

19php use pdo Connection error Connection failed SQLSTATE solution

20php how to connect to and query the SQL database using pdo

21php uses pdo to connect to the mssql server database instance

Detailed explanation on using PDO in 22php

Mysql transaction processing usage instance of pdo in 23php

24php uses PDO to operate MySQL database instances

Output results of various parameters in the 25PHP PDO fetch mode

26 brief introduction to PHP PDO

Comparison and analysis of database connection methods pdo and mysqli in 27php

28PDO anti-injection principle analysis and precautions

Detailed description of mysql connection mode PDO in 29php

30PHP uses PDO to connect to the ACCESS Database

Add, delete, modify, and query databases using PDO in 31php

32 talking about the rowCount function of PDO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.