How to return an integer value referring to the rows in the codeiginter?

2

How do I return an integer value for the rows returned in the select?

$query = $this->db->where("categoria_titulo", $categoria);
$query = $this->db->get("categorias");
$query = $query->num_rows();
echo $query;
    
asked by anonymous 10.08.2015 / 23:23

1 answer

1

Set a variable for the number of records search:

                $query = $this->db->where("categoria_titulo", $categoria);
                $query = $this->db->get("categorias");
                $query_num = $query->num_rows();
                echo $query_num;

Or do

                $query = $this->db->where("categoria_titulo", $categoria);
                $query = $this->db->get("categorias");
                return $query->num_rows();
    
10.08.2015 / 23:24