Welcome Guest, Not a member yet? Register   Sign In
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 CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB