CodeIgniter Forums
Use numbers as field names - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Use numbers as field names (/showthread.php?tid=31973)



Use numbers as field names - El Forum - 07-08-2010

[eluser]Unknown[/eluser]
Hi!

I have a table which have some fields named after years like 2008, 2007, 2006 and so on.

When I run this
Code:
function getAllNames()
    {
        $q = $this->db->get('pojknamn');
        
        if($q->num_rows() > 0){
        
            foreach($q->result() as $row){
                $data[] = $row;
            }
            
            return $data;
        }
        
    }

It only gives me the 'id' and 'name' fields. Isn't it allowed to use numbers only in field names?


Use numbers as field names - El Forum - 07-08-2010

[eluser]danmontgomery[/eluser]
Variables can't start with numbers, result() returns an object. Object members are variables, so they can't start with numbers either... Use result_array() instead