why does this model work in PHP5 but not PHP4.4?

I have made this on my mac, which I realized has the latest version of PHP so my guess is what this is not working?

To remove all the IF ELSE PHP logic from view, I moved it to the model, but maybe this logic is also wrong?

Basically any of the new properties like "foundclass", "hasTruppengattung", etc. don't show up on my webserver with PHP4 and instead just returns "Message: Undefined property: foundclass".

Thank you for any help you can provide.

class Bayern_model extends Model {
    function getAll() {

        $q = $this->db->query("SELECT * FROM people ORDER BY last_name");
        if($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                $data[] = $row;
                $date = explode("-",$row->birthdate);
                //date("d M Y", mktime(0, 0, 0, $date[0], $date[1], $date[2]))
                $row->birthinfo = ($row->birthdate!="0000-00-00") ? "geb. " . date("d M Y", mktime(0, 0, 0, $date[1], $date[2], $date[0])) : "";
                $row->birthinfo .= ($row->birthplace!="") ? ", " . $row->birthplace : "";
                $row->foundclass = ($row->isFound) ? "found" : "notfound";                
                $row->hasTruppengattung = ($row->truppengattung!="") ? true : false ;
                $row->hasFormation = ($row->formation!="") ? true : false ;
                $row->hasTruppenteil = ($row->truppenteil!="") ? true : false ;        
                $row->hasServiceInfo = ( $row->hasTruppengattung || $row->hasFormation || $row->hasTruppenteil ) ? true : false ;
                $row->hasNotes = ($row->notes!="") ? true : false ;                
                $row->hasSource = ($row->sourceLink!="") ? true : false ;
                $row->hasScan = ($row->recordScan!="") ? true : false ;
                $row->searchURL = "http://mywebsite/?firstname" . $row->first_name . "&lastname;=" . $row->last_name;
                    $row->searchURL .= "&birthyear;=" . $date[0];
        return $data;

Do you have access to the PHP errors log?

I don't think so, but I saw that Code Igniter can make its own error logs. Should I try that?

Maybe this is the problem... shouldn't the $data[] = $row; be at the end of your foreach?
As you do it now, $data doesn't contain any new values like 'foundclass' etc... because it's been set before they are declared.

Anyways, CodeIgniter only logs application related information, there's no php or mysql errors logged there.
You can still try switching your local webserver to PHP4 and test it there.

Brilliant! Thanks a lot!

That was it! Funny how the newer version of PHP allows bad code. hehe. Cheers!

I think it doesn't work in both PHP4/5, but maybe you just have a different errors report setting.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.