Hi I cant get my query to return any values from database. I have this function:
private function Query($sql, $arg){
require "conection.php";
$q = $db->prepare($sql);
$q->execute($arg);
$result = $q->get_result();
return $result;
}
I've tried many different PDO statements but all give the same error code [Call to undefined method PDOStatement] I've tried binding results, fetch all... etc but nothing works.. This is my conection.php:
$host = "127.0.0.1";
$dbname = "truckla";
$username = "root";
$password = "123456";
try{
$db = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
}catch(Exception $e){die("Fatal error: ".$e->getMessage());}
This is the following query and how Im calling it:
$result = $this->Query("SELECT OrderId,Products,Quantis,Description,RecvrName,AddressInfo,GPS,TimeStart,TimeSpec FROM orders WHERE IsPrivate LIKE 'false' AND IsComplete LIKE 'false' AND StillOpen LIKE 'true' AND CanShow LIKE 'true' AND TruckType LIKE '%?%' OR ((GroupId LIKE '%?%' OR DriversId LIKE '%?%') AND IsComplete LIKE 'false' AND StillOpen LIKE 'true' AND CanShow LIKE 'true')", array($trucktype,$groupsId,$driverId));
The query works fine in phpMyAdmin and I can get the values if i call it like this:
$result = mysqli_query($conn , $sql);
But I dont trust in escaping bad chars and just run the query, how can I call the query and get the values! Is it a configuration error because no PDO statement is valid... Im using PHP 7.2.10, MySQL and XAMPP 3.2.2 thanks in advance!