Welcome Guest, Not a member yet? Register   Sign In
Making queries through call_user_func_array
#1

[eluser]ilSignorCarlo[/eluser]
Hi,
I'm writing a CodeIgniter model whith some database utilities. What I'm trying to do is to write a function to create customizable queries.

The idea is to pass to the function a table name, a number (to limit results), and an optional array with parameters for the "where" clause. Inside the function I just test if the array is not empty and just in this case I use the "where" clause.

I'm pretty new to PHP and to CodeIgniter too, but I found that I can do this with the call_user_func_array function.

so I call it this way:

Code:
if (!empty($where_array)) {
     call_user_func_array(array(&$this->db, 'where'), $where_array);          
       }

The problem, I think, is that where() needs a pair of values. How can I do this?

Anyway, is what I'm trying to do a good practice?

Thanks,
Bye


Messages In This Thread
Making queries through call_user_func_array - by El Forum - 04-26-2009, 07:06 AM
Making queries through call_user_func_array - by El Forum - 04-26-2009, 07:11 AM
Making queries through call_user_func_array - by El Forum - 04-26-2009, 07:32 AM
Making queries through call_user_func_array - by El Forum - 04-26-2009, 07:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB