Guest User

Untitled

a guest
May 18th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. parametrized query issue in dao in php
  2. function queryByContentAndCreatedBy($city,$min,$max){
  3. $sql = "SELECT id FROM users WHERE city=? LIMIT ?,? ";
  4. $sqlQuery = new SqlQuery($sql);
  5. $sqlQuery->setString($city);
  6. $sqlQuery->setNumber($min);
  7. $sqlQuery->setNumber($max);
  8. return $this->executeUpdate($sqlQuery);
  9. }
  10.  
  11. public static function executeUpdate($sqlQuery){
  12. $transaction = Transaction::getCurrentTransaction();
  13. if(!$transaction){
  14. $connection = new Connection();
  15. }else{
  16. $connection = $transaction->getConnection();
  17. }
  18. $query = $sqlQuery->getQuery();
  19. $result = $connection->executeQuery($query);
  20. if(!$result){
  21. throw new Exception(mysql_error());
  22. }
  23. return mysql_affected_rows();
  24. }
  25.  
  26. public function executeQuery($sql){
  27. return mysql_query($sql, $this->connection);
  28. }
  29.  
  30. You have an error in your SQL syntax ... near ('Pu'm','d'Artagnan','sdsd') at line 1
  31.  
  32. $sql = "SELECT id FROM users WHERE city IN (?,?)";
  33.  
  34. $dbh->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
Advertisement
Add Comment
Please, Sign In to add comment