Welcome Guest, Not a member yet? Register   Sign In
Fill forms with db result!
#5

[eluser]eoinmcg[/eluser]
Hi webbhelp,

One workaround I've done in the past is to have a method in the model that returns any empty object based on the table structure.
So, for example, when needed;
Code:
if(!$query->num_rows())
            {
                $this->empty_row('table_name');
            }

and the method itself...

Code:
function empty_row($table)
    {

        $query = $this->db->query('SELECT * FROM '.$table.' LIMIT 1');

        foreach ($query->list_fields() as $field)
        {
           $row->$field = '';
        }

        return $row;

    }

Of course you can refine this to select only certain fields etc but you get the general idea.

Hope this is of some help


Messages In This Thread
Fill forms with db result! - by El Forum - 12-10-2009, 11:32 AM
Fill forms with db result! - by El Forum - 12-10-2009, 11:37 AM
Fill forms with db result! - by El Forum - 12-10-2009, 11:43 AM
Fill forms with db result! - by El Forum - 12-10-2009, 11:51 AM
Fill forms with db result! - by El Forum - 12-10-2009, 01:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB