4
I take the category ID, and with it I search the subcategories. For this I am using WHERE’s. How would you look using INNER JOIN?
The WHERE’s thing got me confused
<?php
namespace Application\Models;
use Application\Models\Model;
class ComboModel extends Model
{
public function subcategoria(){
$args = func_get_args();
if(count($args) == 1 && is_array($args[0])){
$categoria = strip_tags($args[0]['categoria']);
$id_categoria = $this->db->prepare("SELECT `id` FROM `admin_categorias` WHERE `categoria` = :categoria");
$id_categoria->bindValue(":categoria", $categoria, \PDO::PARAM_STR);
$id_categoria->execute();
$id = $id_categoria->fetchObject();
$subcategorias = $this->db->prepare("SELECT `subcategoria` FROM `admin_subcategorias` WHERE `id_categoria` = :id ORDER BY `subcategoria` ASC");
$subcategorias->bindValue(":id", $id->id, \PDO::PARAM_INT);
$subcategorias->execute();
return $subcategorias->fetchAll();
} else {
return false;
}
}
}
returns nothing :(
– Jonathan Silva
ops, I got kkkk would be where
admin_categorias
.categoria
= :category– Jonathan Silva
I’m glad you did it even with my distraction, I’ll edit it to match your example. ^^
– Robson gomes de jesus