Welcome Guest, Not a member yet? Register   Sign In
clear active record
#6

[eluser]Cesar Kohl[/eluser]
I didn't understand your example, so I'll use another one:

Code in controller:

Code:
//Assume there is a table with 4 rows: id, phrase, tags, id_author
        echo '<pre>';
        
        //Selects the row 'phrase' with 'id=24' on table 'phrases'
        $this->db->select('phrase');
        $this->db->where('id',24);
        $contact1 = $this->db->get('phrases');
        
        print_r($contact1->row_array());
        
        
        //Selects rows 'id' and 'phrase' with 'id=24' on table 'phrases'
        $this->db->select('id,phrase');
        $this->db->where('id',24);
        $contact2 = $this->db->get('phrases');
        
        print_r($contact2->row_array());
        
        
        //Selects all rows with 'id=24' on table 'phrases'
        $this->db->select('');//this line can be deleted
        $this->db->where('id',24);
        $contact3 = $this->db->get('phrases');
        
        print_r($contact3->row_array());

Output in browser:

Quote:Array
(

[phrase] => The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed.
)

Array
(

[id] => 24
[phrase] => The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed.
)

Array
(

[id] => 24
[phrase] => The truth is you don't know what is going to happen tomorrow. Life is a crazy ride, and nothing is guaranteed.
[tags] => truth life
[id_author] => 22
)

Any questions?


Messages In This Thread
clear active record - by El Forum - 12-14-2010, 07:08 AM
clear active record - by El Forum - 12-14-2010, 07:26 AM
clear active record - by El Forum - 12-14-2010, 07:44 AM
clear active record - by El Forum - 12-14-2010, 07:46 AM
clear active record - by El Forum - 12-14-2010, 07:50 AM
clear active record - by El Forum - 12-14-2010, 08:41 AM
clear active record - by El Forum - 12-14-2010, 08:47 AM
clear active record - by El Forum - 12-14-2010, 09:05 AM
clear active record - by El Forum - 12-14-2010, 09:46 AM
clear active record - by El Forum - 12-14-2010, 09:47 AM
clear active record - by El Forum - 12-14-2010, 11:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB