P2GR / datamapper

CodeIgniter Datamapper
Other
35 stars 23 forks source link

Fatal error: Call to a member function num_rows() on a non-object in datamapper.php on line 6321 #13

Open ItsJustATypo opened 9 years ago

ItsJustATypo commented 9 years ago

Hi,

I'm using DM 1.8.2. I get the error:

Fatal error: Call to a member function num_rows() on a non-object in datamapper.php on line 6321

My DataMapper.php:

    protected function _process_query($query)
    {
        if ($query->num_rows() > 0)   //  <----- this is line 6321
        {

when I execute this query in CI 2.1.0:

$objRules->query($sql);

using this $sql (see explanation below):

CREATE TEMPORARY TABLE IF NOT EXISTS rules_list_1 AS 
(SELECT `rules`.*, `vendors`.`name` AS vendor_name, `accounts`.`name` AS account_name, 
`qb_classes`.`name` AS qb_class_name, 
`account_sys_lookups`.`int_value` AS account_sys_lookup_int_value
FROM (`rules`)
LEFT OUTER JOIN `vendors` vendors ON `vendors`.`id` = `rules`.`vendor_id`
LEFT OUTER JOIN `accounts` accounts ON `accounts`.`id` = `rules`.`account_id`
LEFT OUTER JOIN `qb_classes` qb_classes ON `qb_classes`.`id` = `rules`.`qb_class_id`
LEFT OUTER JOIN `sys_lookups` account_sys_lookups 
ON `account_sys_lookups`.`id` = `accounts`.`type_id`
WHERE `rules`.`user_id` =  1
ORDER BY `rules`.`search_string`)

What this query does:

This query works in phpMyAdmin. It fails when running it within CI and DM.

Any idea what I need to do in order to get this working?