Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:50:15+00:00 2026-05-27T06:50:15+00:00

I am using a phpdao for my database operation. When I run this code

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:50:15+00:00Added an answer on May 27, 2026 at 6:50 am

    you are doing it wrong.
    and solution from the linked question won’t help you.

    if your “phpdao” doesn’t have a setArray() method, you have to create the query manually.

    1. Create a string that looks like (?,?,?,?,?,?) where number of ?s is equal to the number of members of your array.
    2. add this string into your query
    3. bind your array members in a loop.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using emacs on Ubuntu 11.10. I want to connect to a SQL Server database
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
Using a Microsoft version of SQL, here's my simple query. If I query a
Using Lightbox for a photo gallery and would like to initiate the function by
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using NSDateComponents I know how to get the day component, but this gives me
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
using file_get_contents , I open an Internet URL and get the contents of this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.