I get the category ID, and with it I look for the subcategories. For this I am using WHERE's. How would you use INNER JOIN?
The WHERE's question confused me
<?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;
}
}
}