Welcome Guest, Not a member yet? Register   Sign In
Manipulating query results
#1

[eluser]kjackson7_93[/eluser]
I have an application that queries a table. A field in the table is the name of a file that should be in the file system. I'd like to loop through the results, test to make sure the file exists. Currently (not CI nor MVC) I do:

Code:
$notes_sth = $dbh->prepare($sql);
$notes_sth->execute(array($_SESSION['userid']));
while ($rec = $notes_sth->fetch()){
    $rec['has_external_doc'] = file_exists(DOCUMENTROOT."/notes/".$rec['board_notes_id'].$rec['filename_ext']) ? 1 : 0;
    $notes_array[] = $rec;
}

Using CI, in my model I do:
Code:
$board_notes = $this->db->get('board_notes');
return $board_notes->result();

How can I loop through $board_notes->results, insert "has_external_doc" and still return the same data structure as $board_notes->result()?

Thanks in advance.


Messages In This Thread
Manipulating query results - by El Forum - 03-05-2008, 11:52 AM
Manipulating query results - by El Forum - 03-05-2008, 11:26 PM
Manipulating query results - by El Forum - 03-06-2008, 08:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB