What does the colon in a mysql statement mean? How can this problem be solved?

Source: Internet
Author: User
What does the colon in a mysql statement mean? What does the colon in a mysql statement mean ?, $ Db-& gt; bandVars (); transfer value & nbsp; echo $ check_query; now you know ., Can you refer to the PHPcode & lt; of the pdo class in the manual ;? Php/* E what does the colon in mysql statements mean?
What does the colon in a mysql statement mean?


------ Solution --------------------
$ Db-> bandVars (); pass value
Echo $ check_query.
------ Solution --------------------
Let's take a look at the pdo class in the manual.
PHP code
  Prepare ('select name, color, calories FROM fruit WHERE calories <: calories AND color =: color'); $……> bindParam (': calories', $ calories, PDO:: PARAM_INT); $……-> bindParam (': color', $ color, PDO: PARAM_STR, 12); $……-> execute ();?>
------ Solution --------------------
There are no other symbols to distinguish them from SQL syntax.
The bindVars method associates the defined symbols with the actual variables.
------ Solution --------------------
PHP code
Example #1 Execute a prepared statement with named placeholders
    prepare('SELECT name, colour, calories    FROM fruit    WHERE calories < :calories AND colour = :colour');$sth->bindParam(':calories', $calories, PDO::PARAM_INT);$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);$sth->execute();?>Example #2 Execute a prepared statement with question mark placeholders
    prepare('SELECT name, colour, calories    FROM fruit    WHERE calories < ? AND colour = ?');$sth->bindParam(1, $calories, PDO::PARAM_INT);$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);$sth->execute();?>

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.