Hello I was building my Query class which I saw on YouTube, but I'm stuck. My Query function that allows you to use advanced SQL queries like SELECT * FROM market LIMIT ? OFFSET ?
It binds values so I can't find any solution. Anybody help? What should I do?
My Query.php class contains
public function query($sql, $params = array())
{
$this->_error = false;
if ($this->_query = $this->db->prepare($sql))
{
$x = 1;
if (count($params))
{
foreach ($params as $param)
{
$this->_query->bindValue($x, $param);
$x++;
}
}
if ($this->_query->execute())
{
$this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
$this->_count = $this->_query->rowCount();
} else {
$this->_error = true;
}
}
return $this;
}
Here I tried to select items from db like it's in my Query bellow
$i = 3;
$x = 100;
$sql = Query::getInstance()->query("SELECT * FROM market LIMIT ? OFFSET ?", array($i, $x));
var_dump($sql);
I didn't put here full source code, I think there is a problem in query function but I'm not able to find it.