Welcome Guest, Not a member yet? Register   Sign In
Is there a way to auto generate CRUD for multiple tables?
#2

[eluser]überfuzz[/eluser]
[quote author="Aken" date="1252344263"]...

You could even have a private function inside your model that does the actual DB retrieve, and just define some variables for each situation in the rest of your functions.

Code:
function getDB1()
{
    $params = array(
        'column1' => 'this',
        'column2' => 'this',
        'table1' => 'this',
        'table2' => 'this'
    );
    
    return $this->parse($params);
}

function getDB2()
{
    $params = array(
        'column1' => 'this',
        'column2' => 'this',
        'table1' => 'this',
        'table2' => 'this'
    );
    
    return $this->parse($params);
}

private function parse($params)
{
    $this->db->select($params['table1'].'.'.$params['column1'].' AS when');
    $this->db->select($params['table2'].'.'.$params['column2'].' AS event');
    
    return $this->db->return_array();
}
[/quote]

I've got this suggestion when I posted a similar question. It really helped me, it makes the db-handling nice and tidy when you're using the same query on different tables.


Messages In This Thread
Is there a way to auto generate CRUD for multiple tables? - by El Forum - 09-26-2009, 08:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB