Ben hazırlanıp php mysqli uzantısı kullanıyorum, ama bir sorguyu bu sorgu nesnesi yaratmak değil.
İşte kod:
$sqlq = "SELECT id,name FROM productcategories JOIN products ON productcategories.productid = products.id WHERE categoryid=?";
if($allsubcats)
{
foreach($allsubcats as $key => $data)
{
$sqlq .= " OR categoryid=?";
}
}
echo $sqlq;
if($query = $this->mysqli->connection->prepare($sqlq))
{
$query->bind_param("i", $cat);
if($allsubcats)
{
foreach($allsubcats as $key => $data)
{
$query->bind_param("i", $data[0]);
}
}
$query->execute();
$query->bind_result($id,$name);
$query->store_result();
if($query->num_rows > 0)
{
while($row = $query->fetch())
{
$allprods["id"] = $id;
$allprods["name"] = $name;
}
}
$query->close();
}
Sorun:
The line if($query = $this->mysqli->connection->prepare($sqlq))
The if()
is returning false, and therefore not creating the $query
object, and not executing any of the code inside the if.
echo $sqlq;
döner:
"SELECT id,name FROM productcategories JOIN products ON productcategories.productid = products.id WHERE categoryid=? OR categoryid=? OR categoryid=? OR categoryid=? OR categoryid=? OR categoryid=?"
Ben yanlış bir şey görmüyorum ki.
Herhangi bir yardım büyük mutluluk duyacağız,
Teşekkürler, Nico