Which of the following questions can help you change the regular expression?

Source: Internet
Author: User
I want to simulate the bindParam function of Pdo and write a short answer code, as shown in the following code: Check the link. I can't determine the code of a large segment: code image display the above Code can basically implement the simple binding function, and the result will be pulled: {code ...} but in special cases, it will not work, for example :... I want to simulate the bindParam function of Pdo.

I wrote a simple piece of code, as shown below: Check the link. I can't decide a large piece of code: the code image shows that the above Code can basically implement the simple binding function and will output the pull result:

SELECT * from table where conId = 1 AND title LIKE 'test' AND created <= '000000' order by conId desc limit 1

But in special cases, this will not work, for example:

$sql = "SELECT * FROM TABLE WHERE conId=:id AND test=:idte AND title LIKE :kw AND created<=:time ORDER BY conId DESC  LIMIT 1";

$ Args = array ('id' => 1, 'idte' => 'tester', 'kw '=> 'test', 'time' => 12312321312 ); modify both $ SQL and $ args, and the output results will be messy. See "test = 1te" here.

SELECT * from table where conId = 1 AND test = 1te AND title LIKE 'test' AND created <= '000000' order by conId desc limit 1

Reply content:

I want to simulate the bindParam function of Pdo.

I wrote a simple piece of code, as shown below: Check the link. I can't decide a large piece of code: the code image shows that the above Code can basically implement the simple binding function and will output the pull result:

SELECT * from table where conId = 1 AND title LIKE 'test' AND created <= '000000' order by conId desc limit 1

But in special cases, this will not work, for example:

$sql = "SELECT * FROM TABLE WHERE conId=:id AND test=:idte AND title LIKE :kw AND created<=:time ORDER BY conId DESC  LIMIT 1";

$ Args = array ('id' => 1, 'idte' => 'tester', 'kw '=> 'test', 'time' => 12312321312 ); modify both $ SQL and $ args, and the output results will be messy. See "test = 1te" here.

SELECT * from table where conId = 1 AND test = 1te AND title LIKE 'test' AND created <= '000000' order by conId desc limit 1

How can I change add_quote to this?

function add_quote($v){  $v = preg_quote(':', $v);  return $v.'\b/';}

Here is a regular expression tutorial that describes related issues:
Http://deerchao.net/tutorials/regex/regex.htm#getstarted

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.