Esempio n. 1
0
 function testSql_PrepareNamedArgs()
 {
     $Sql_Prepare = new A_Sql_Prepare(':foo :bar :baz', array(':foo' => 1, ':bar' => 2, ':baz' => 3));
     $this->assertEqual($Sql_Prepare->render(), "1 2 3");
     $Sql_Prepare = new A_Sql_Prepare(':foo :bar :baz');
     $this->assertEqual($Sql_Prepare->bind(array(':foo' => 1, ':bar' => 2, ':baz' => 3))->render(), "1 2 3");
     $Sql_Prepare = new A_Sql_Prepare();
     $this->assertEqual($Sql_Prepare->statement(':foo :bar :baz')->bind(array(':foo' => 1, ':bar' => 2, ':baz' => 3))->render(), "1 2 3");
     // test auto-prefixing param
     $Sql_Prepare = new A_Sql_Prepare();
     $this->assertEqual($Sql_Prepare->statement(':foo :bar :baz')->bind(array('foo' => 1, 'bar' => 2, 'baz' => 3))->render(), "1 2 3");
 }
Esempio n. 2
0
<?php

include 'config.php';
$prepare = new A_Sql_Prepare("INSERT mytable SET one=?, two='?', three=:three, three=?");
$prepare->bind("foo's", array(':three' => 'faz'), 'bar', 1);
echo "Default is escaping, but no quoting<br/>A_Db_Prepare::render=" . $prepare->render() . '<br/>';
$prepare = new A_Sql_Prepare("INSERT mytable SET one=?, two=?, three=:three, three=?");
$prepare->quoteValues()->bind("foo's", array(':three' => 'faz'), 'bar', 1);
echo "With quoting on by calling quoteValues()<br/>A_Db_Prepare::render=" . $prepare->render() . '<br/>';
#dump($prepare);