I am using a phpdao for my database operation. When I run this code there is a error
function queryByContentAndCreatedBy($city,$min,$max){
$sql = "SELECT id FROM users WHERE city=? LIMIT ?,? ";
$sqlQuery = new SqlQuery($sql);
$sqlQuery->setString($city);
$sqlQuery->setNumber($min);
$sqlQuery->setNumber($max);
return $this->executeUpdate($sqlQuery);
}
public static function executeUpdate($sqlQuery){
$transaction = Transaction::getCurrentTransaction();
if(!$transaction){
$connection = new Connection();
}else{
$connection = $transaction->getConnection();
}
$query = $sqlQuery->getQuery();
$result = $connection->executeQuery($query);
if(!$result){
throw new Exception(mysql_error());
}
return mysql_affected_rows();
}
Connection.php
public function executeQuery($sql){
return mysql_query($sql, $this->connection);
}
Then there is a error :
You have an error in your SQL syntax ... near ('Pu\'m','d\'Artagnan','s\dsd') at line 1
Similar error is for this query
$sql = "SELECT id FROM users WHERE city IN (?,?)";
In PDO this is a solution : see details
$dbh->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
Whats is a equivalent solution for this for my dao ?