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 8251905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:23:29+00:00 2026-06-08T00:23:29+00:00

Below is a function designed to handle a search scenario for a custom class.

  • 0

Below is a function designed to handle a search scenario for a custom class.

I’ve already tripped over the fact that PDO defaults to binding parameters as strings, causing an integer->string conversion even if it’s not appropriate. As you’ll see, I corrected that by manually checking if the type is integer and then forcing the use of int in those cases. Problem is, my solution only works for a ‘start’ value of 0 — anything higher errors out, and I don’t know why. If I manually set the start/count values to their appropriate values ( i. e. instead of :count I use {$count}), everything works fine, so it looks like the binding is still messing up.

How? Or if I’m wrong… what is right?

    /*Query is:  
    SELECT tutor_school.id 
    FROM tutor_school, tutor_states 
    WHERE tutor_states.stateName=:state AND tutor_states.id=tutor_school.state 
    GROUP BY tutor_school.id order by tutor_school.name asc 
    LIMIT :start, :count*/

    $db = Database::get_user_db();
    $statement = $db->prepare($query);
    foreach ($executeArray as $key => $value)
    {
        if (getType($value) == 'integer')
        {
            $statement->bindParam($key, $executeArray[$key], PDO::PARAM_INT);
        }
        else
        {
            $statement->bindParam($key, $value);
        }
    }
    var_dump($executeArray);//count and start are still ints
    if ($statement->execute())
    {
        var_dump($executeArray);//start and count are now strings
        var_dump($statement->errorInfo());
        var_dump($query);
        $values = $statement->fetchAll();
        $return = array();
        foreach ($values as $row)
        {
            $school = School::schoolWithId($row[0]);
            if (!empty($school))
            {
                $return[] = $school;
            }
        }
        return $return;
    }
  • 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-06-08T00:23:32+00:00Added an answer on June 8, 2026 at 12:23 am

    Metadata (such as the LIMIT arguments) can’t be parametrized. You will have to use (properly sanitized) interpolation instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that is designed to dynamically load a .dll or .so
The function below is designed to take an input hex (with or without the
The class below is designed to manipulate a cisco-like device interface, for the purpose
Suppose a scenario like below : Class User {} // User has Admin Role
The function below is designed to apply rel=nofollow attributes to all external links and
I have this VBA below that is designed to loop through each WS and
The script below resides in my theme's functions.php file. It is designed to show
When I put the below function into leon repl , I get java.lang.IllegalArgumentException: Wrong
I am using the below function of javascript to enable and disable the radio
Anyone experienced exception using below function? tdse.GetObject(tmpFolderWebDavURL, EnumOpenMode.OpenModeView, null, XMLReadFilter.XMLReadAll) as Folder; Seems if

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.