Welcome Guest, Not a member yet? Register   Sign In
Printing only NOT NULL datas from MySql query
#2

[eluser]Phil Sturgeon[/eluser]
Surely just:

Code:
function get_profileByID($id)
    {
        $query = $this->db->getwhere('nip_profile', array('profile_ID' => $id, 'active' => 1));

        // Is there any results ?
        if(!$query->num_rows() > 0)
        {
            return false;
        }


        // @TODO: Tester tous les champs NULL et ne renvoyer que ceux-ci pour n'afficher que ceux-ci


        foreach($query->result() as $row)
        {
            $data = array(  'is_human'      => $row->is_human,
                            'active'        => $row->active,
                            'created'       => $row->created,
                            'modified'      => (isset($row->modified) ? $row->modified : '',          // Possible NULL
                            'name'          => $row->name,
                            'website'       => (isset($row->website) ? $row->website : '',           // Possible NULL
                            'origin'        => (isset($row->origin) ? $row->origin : '',            // Possible NULL
                            'based_at'      => (isset($row->based) ? $row->based_at : '',          // Possible NULL
                            //etc
            );

            // If birthdate is not Null, we convert it to Age
            if($row->date_of_birth)
            {
                $data['age'] = mysqldate_to_age($row->date_of_birth);
            }

        }

        return $data;
    }


Messages In This Thread
Printing only NOT NULL datas from MySql query - by El Forum - 07-31-2007, 06:25 PM
Printing only NOT NULL datas from MySql query - by El Forum - 08-01-2007, 04:30 AM
Printing only NOT NULL datas from MySql query - by El Forum - 08-01-2007, 07:00 AM
Printing only NOT NULL datas from MySql query - by El Forum - 08-01-2007, 07:17 AM
Printing only NOT NULL datas from MySql query - by El Forum - 08-01-2007, 07:32 AM
Printing only NOT NULL datas from MySql query - by El Forum - 08-01-2007, 07:47 AM
Printing only NOT NULL datas from MySql query - by El Forum - 08-01-2007, 07:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB