Welcome Guest, Not a member yet? Register   Sign In
Query Binding
#5

[eluser]bretticus[/eluser]
[quote author="James Brauman" date="1250015057"]To do a query binding, you have to use this syntax:
Code:
$sql = 'SELECT ? FROM ? LIMIT ?';
$query = $this->db->query($sql, array('username', 'users', 10));

However, I would like to use some syntax like this:
Code:
$sql = 'SELECT ? FROM ? LIMIT ?';
$this->db->bind('username', 'users', 10);
$query = $this->db->query($sql);

Is it possible to extend the active record class to acheieve this?[/quote]

How is the first example not binding?

I think alboyd's question is the same as mine. What significant benefit do you get from the syntax in the second form? Yes, there's some separation from the query call and the actual binding, but your pseudo code in the $sql variable is useless without binding, so why is it important to have that separation?

The nice thing about codeigniter is you can rewrite it how you like. It's just PHP code. I say rewrite because I believe the data class is one of the core libs that you can't extend in the usual way. It would most likely take some hacking of the CI core to create the alternate syntax. A seasoned PHP developer familiar with OOP experience ought to be able to look under the hood and extend the database library. But I doubt anyone has done this before so you are probably on your own.


Messages In This Thread
Query Binding - by El Forum - 08-11-2009, 07:24 AM
Query Binding - by El Forum - 08-25-2009, 05:22 PM
Query Binding - by El Forum - 08-25-2009, 05:33 PM
Query Binding - by El Forum - 08-25-2009, 05:42 PM
Query Binding - by El Forum - 08-26-2009, 12:46 AM
Query Binding - by El Forum - 03-06-2010, 05:11 PM
Query Binding - by El Forum - 11-25-2010, 01:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB