i'm trying to query for some data from a table here is the query i send to the pdo
$query ="select ads.adID from ads,ad_content where ads.adID=ad_content.adID and city = amsterdam and EXISTS(select 1 from ad_content where ad_content.name = air_conditioner and ad_content.value =1)";
here is the pdo function im using:
public function readDBNoStoredProcedure($query ,$arr=[])
{
//call the passed query and read not stored procedure
self::connect();
$statement = self::$connection->prepare($query);
$check = $statement->execute($arr);
if ($check) {
/**
* PDO::FETCH_OBJ : returns an anonymous object with property names that correspond
* to the column names returned in your result
*/
$result = $statement->fetchAll(PDO::FETCH_OBJ);
self::disconnect();
if (is_array($result) && count($result) > 0) {
return $result;
}
return false;
}
self::disconnect();
return false;
}
and the tables are like this for ads-
| adId | city |
|---|---|
| 1 | amsterdam |
| 2 | new york |
and adContent is:
| adId | name | value |
|---|---|---|
| 1 | air_conditioner | 1 |
| 1 | garden | 0 |
the error is:
<b>Fatal error</b>: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'amsterdam' in 'where clause' in C:\xxa\htdocs\home\api\system\classes\useDBs.php:151
Stack trace:
#0 C:\xxa\htdocs\home\api\system\classes\useDBs.php(151): PDOStatement->execute(Array)
#1 C:\xxa\htdocs\home\home-app\api.php(100): dbClass->readDBNoStoredProcedure('select ads.adID...', Array)
#2 C:\xxa\htdocs\home\home-app\api.php(349): getAdsIdThatFeetSearch()
#3 {main}
thrown in <b>C:\xxa\htdocs\home\api\system\classes\useDBs.php</b> on line <b>151</b><br />