• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help on count function error

#1
Hi,

I am encountering the error:

Message: count(): Parameter must be an array or an object that implements Countable

I am using it as:

if (count($query)>0)

{


...

}

Need help on how to resolve the issue
Reply

#2
// 1.create the data object
$data = new stdClass();
$data->query = $query;

// 2.create the array data
$data = [];
$data['query'] = 'SELECT ...';
Reply

#3
Why not use this?

PHP Code:
    // -----------------------------------------------------------------------

    /**
     * get()
     *
     * @param  string $orderBy
     * @return object
     */
    
public function get($orderBy '')
    {
        
$data = [];

        
$query $this->db->order_by($orderBy)->get($this->tableName);

        if (
$query->num_rows() > 0)
        {
            
$data $query->result();
        }

        
$query->free_result();
        
        return 
$data;
    } 
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.