Welcome Guest, Not a member yet? Register   Sign In
Asking about performance of data retrieval
#3

[eluser]jedd[/eluser]
Indeed.

This is slightly neater:
Code:
//get one field value
    function get_shop($type){
        $this->db->select($type);
        $this->db->from('shop');
        $query = $this->db->get();
        if ($query->num_rows() == 1)  {
                $row = $this->db->row();
                return $row->$type;
                }
        return FALSE;
    }

I check for =1 so it stands out if you're returning > 1 element in this query (presumably that's a bad thing and you want to know about it).
I think with PHP5 you can chain things in that if block, but AR calls aren't my forte.


Messages In This Thread
Asking about performance of data retrieval - by El Forum - 09-10-2009, 07:12 PM
Asking about performance of data retrieval - by El Forum - 09-11-2009, 12:01 AM
Asking about performance of data retrieval - by El Forum - 09-11-2009, 04:02 AM
Asking about performance of data retrieval - by El Forum - 09-11-2009, 07:12 AM
Asking about performance of data retrieval - by El Forum - 09-11-2009, 07:31 AM
Asking about performance of data retrieval - by El Forum - 09-11-2009, 04:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB