2
2
2slide2014-03-02 19:45:29
MySQL
2slide, 2014-03-02 19:45:29

Fetching join codeigniter count lines?

there are two tables
blogi
id blog_cate
1 batabase
2 batabase
3 razrabotka
4 sql
blog_cate
id blogi_cate_title blogi_cate_url
1 Databases batabase
2 PHP
3 Development razrabotka
Need to make a selection
to be like this
Databases 2
Development 1
PHP 0

<br>
$this->db->select('blogi_cate.*, COUNT(blogi.blog_cate) as num');<br>
$this->db->join('blogi', 'blogi.blog_cate = blogi_cate.blogi_cate_url');<br>
$query = $this->db->get('blogi_cate');     <br>

Only one match does not work correctly
Array
(
[0] => stdClass Object
(
[blogi_cate_id] => 3
[blogi_cate_title] => Databases
[blogi_cate_url] => database
[num] => 15
)
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2014-03-02
@ShVad

There is a method $this->db->count_all_results();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question