What does a colon in a MySQL statement mean? How to solve it

Source: Internet
Author: User
What does a colon in a MySQL statement mean?
What does a colon in a MySQL statement mean?


------Solution--------------------
$db->bandvars (); Passing values
echo $check _query; Will know.
------Solution--------------------
Can look at the brochure PDO class
PHP Code
  Prepare (' SELECT name, colour, calories from fruit WHERE calories <: calories and colour =: Colour '); $sth->bind Param (': Calories ', $calories, PDO::P aram_int), $sth->bindparam (': Colour ', $colour, PDO::P aram_str,); $sth Execute ();? >
------Solution--------------------
There is no other meaning in the notation, so that it differs from the syntax component of SQL
The Bindvars method associates the defined symbol with the actual variable.
------Solution--------------------
PHP code
example #1 Execute a prepared statement with named place Holders!--? php/* Execute A prepared statement by binding PHP variables */$calories =; $colour = ' red '; $sth = $dbh-- ->prepare (' SELECT name, colour, calories from fruit WHERE calories <: calories and colour =: Colour '); $sth->bi Ndparam (': Calories ', $calories, PDO::P aram_int), $sth->bindparam (': Colour ', $colour, PDO::P aram_str,); $sth- >execute ();? >example #2 execute a prepared statement with question mark placeholders the!--? php/* Execute a prepared statement by B     Inding PHP Variables */$calories =; $colour = ' red '; $sth = $dbh--->prepare (' SELECT name, colour, calories from fruit WHERE calories <? and colour =? '); $sth->bindparam (1, $calories, PDO::P aram_int), $sth->bindparam (2, $colour, PDO::P aram_str, N); $sth Execute ();? > 
  • Related Article

    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.