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

  • Home
  • SEARCH
  • 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 7747821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:37:28+00:00 2026-06-01T10:37:28+00:00

I have a similiar class with a lot of methods, but getData() only returns

  • 0

I have a similiar class with a lot of methods, but getData() only returns the value of the $column parameter.

private $db;

function __construct()
{
    $this->db = new PDO('sqlite:\db');
}

public function getData($rowid, $column)
{
    $st = $this->db->prepare('SELECT ? FROM tbl WHERE rowid=?');
    $st->bindParam(1, $column, PDO::PARAM_STR);
    $st->bindParam(2, $rowid, PDO::PARAM_INT);
    if ($st->execute())
        return $st->fetchColumn();
    else
        return false;
}

Every other parts of the class and the left out half of getData() works. What’s the problem here?

  • 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-01T10:37:30+00:00Added an answer on June 1, 2026 at 10:37 am

    bindParam is used to bind parameters, not identifiers. The value you bind there will be expanded as:

    SELECT 'some_value' FROM tbl WHERE rowid='some_other_value';
    

    …therefore equivalent to:

    SELECT 'some_value';
    

    You should only use parameters for actual parameters:

    $this->db->prepare('SELECT '.$column.' FROM tbl WHERE rowid=?');
    

    If your column is user-supplied and you want to escape it, use the proper escaping function. In this case, it’s SQLite3::escapeString():

    $column = SQLite3::escapeString($column);
    $this->db->prepare('SELECT '.$column.' FROM tbl WHERE rowid=?');
    

    If the column is not user-supplied, you don’t really have to escape it.

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

Sidebar

Related Questions

I have a similar scenario as this one: public class TestLinq2Xml { private XElement
I have a collection similar to: Public Class MyCollection Inherits ObservableCollection(Of MyCollection) Private _Name
I have a similar code snippet like this class Search { public function search($for,
I have a class contains 10 methods which are doing almost the same things
I have a class with a lot of Decimal properties that are used for
I have the following class structure: class Parent { public function process($action) { //
I have a class Similar to this public class Model { public TimeSpan Time1
I have code similar to this in my application: class A { public: int
I have a Project model similar to: class Project(models.Model): ... lead_analyst=models.ForeignKey(User, related_name='lead_analyst') ... I
I have a structure similar to this: class OuterClass{ AnimatorListener sth; public OuterClass(){ sth

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.