Welcome Guest, Not a member yet? Register   Sign In
Active Record "from" question
#1

[eluser]ReGeDa[/eluser]
I have some problem with active record. My database (PostgreSQL) logic consist of some functions like this:

Code:
create function get_data(int,int) returns setof timeline as $$
select * from smth_table where param1 = $1 and param2 = $2
$$ language sql immutable;

Problem at this:

Code:
//...
$table = 'get_data('.$param1.','.$param1.')';
$this->db->from($table);
//...

It's provides failure escaping:

Code:
... get_data(1,"2)"

My solve replaces to:

Code:
// (system/database/DB_active_rec.php:272)
foreach(preg_split('/,[\s]+/', $val, -1, PREG_SPLIT_NO_EMPTY) as $v)
//...

That is, any table statement separated by ", " (with following space)

Code:
//...
$this->db->from('foo, bar, hello(1,1)');
//...

Maybe other ideas...

:roll: Sorry for English




Theme © iAndrew 2016 - Forum software by © MyBB