Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- parametrized query issue in dao in php
- 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();
- }
- public function executeQuery($sql){
- return mysql_query($sql, $this->connection);
- }
- You have an error in your SQL syntax ... near ('Pu'm','d'Artagnan','sdsd') at line 1
- $sql = "SELECT id FROM users WHERE city IN (?,?)";
- $dbh->setAttribute( PDO::ATTR_EMULATE_PREPARES, false );
Advertisement
Add Comment
Please, Sign In to add comment