0

I'm failing to see the problem why I'm getting a pdo error, I'm not missing a simple : or a parameter (since there are only 2)

public function does_stringid_excist($strTable, $strColumn, $strValue)
{
    $sql = "SELECT count(1) AS count FROM tblemployer WHERE :strColumn = :strValue";
    $this->objDatabase->query($sql); //Makes a prepare with the given sql
    // $this->objDatabase->bind_column(':strTable', $strTable);
    $this->objDatabase->bind_column(':strColumn', $strColumn); // Uses the `bindColumn()` from PDO
    $this->objDatabase->bind_value(':strValue', $strValue); // Uses the `bindValue()` from PDO
    $result = $this->objDatabase->single();
    return $result['count'];
}

SELECT count(1) AS count FROM `tblemployer` WHERE `employerID` = :strValue" works just fine so the error isn't with the value.

Wanjia
  • 799
  • 5
  • 19

1 Answers1

0

A column is not the same as a table. Youre using bindColumn to bind a table, which does not work.

See: http://php.net/manual/en/pdostatement.bindcolumn.php

Erik Baars
  • 2,278
  • 1
  • 8
  • 14