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