CodeIgniter Forums
Database driver error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Database driver error (/showthread.php?tid=71381)



Database driver error - mahlenko - 08-08-2018

Hello, make a request to the database:

PHP Code:
// $this->db->last_query()
SELECT COUNT(*) AS `numrows`
FROM `lids`
WHERE   (
`
lids`.`date_inspection` >= '2018-07-08 00:00:00'
AND `lids`.`date_inspection` <= '2018-08-08 23:59:59'
 


Show results: 0
   

When performing the same query directly in the database get:
Show results: 1558
   


RE: Database driver error - mahlenko - 08-08-2018

I'm sorry, I ran the query on another database. Whoops! ))


RE: Database driver error - excellentwebworld - 08-10-2018

Your query absolutely right. i don't know why it is not working.please use below query as a alternative.

$row1 = $this->db->query("SELECT COUNT(*) AS `numrows` FROM `lids` WHERE `lids`.`date_inspection` >= '2016-10-14 00:00:00' AND `lids`.`date_inspection` <= '2016-10-15 23:59:59'")->row();

$row2 = $this->db->query("SELECT COUNT(*) AS `numrows` FROM `lids` WHERE `date_inspection` >= '2016-10-14 00:00:00' AND `date_inspection` <= '2016-10-15 23:59:59'")->row();

$row3 = $this->db->query("SELECT COUNT(*) AS numrows FROM lids WHERE date_inspection BETWEEN '2016-10-14 00:00:00' and '2016-10-15 23:59:59'")->row();

print_r($row1->numrows);
print_r($row2->numrows);
print_r($row3->numrows);

Above three query is may helpful.