简体   繁体   中英

Codeigniter Query doesn't return result value

I got the following snippet to get some userrights out of the db:

    $tmp   = "SELECT REPLACE(group_concat(CAST(".$role." AS CHAR)),',','') AS rights FROM functionrights ORDER BY id ASC";
    $query = $this->CI->db->query($tmp);
    if($query->num_rows()>0){
        $row = $query->row(); 
        return $row->rights;

This returns nothing. If I execute the statement direct everything is ok?! What is wrong here?

Change $this->CI->db->query to $this->db->query

The ->CI is not necessary. Also, you have no } tag (but that could be just a copy/paste thing).

Besides that: ->row() returns one result, while ->result() returns all results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM