Welcome Guest, Not a member yet? Register   Sign In
globally disabling protect identifiers
#7

[eluser]pocketmax[/eluser]
Then that's a bug in code igniter, or they need to update there documentation...

http://ellislab.com/codeigniter/user-gui...ecord.html

Towards the bottom of the page it gives a where example...

Code:
$this->db->where('name', $name);
// Produces: WHERE name = 'Joe'

I ran that exact same example and got

SELECT * WHERE "foo" = 'bar'

They didn't disable protection in there code and they got the result I couldn't get. I guess my conflict is it seems (to me anyway) that the db handling logic is flawed. In order to execute a simple query on my database, I have to explicitly disable things so it won't break. So for example...

Code:
$this->db->select('foo');
$this->db->where('foo','data');
$results = $this->db->get('bar');

will produce
Code:
SELECT "foo" FROM "bar" WHERE "foo" = 'data'
and break my query in three places. In order to prevent that from happening, I have to globally turn something off...

Code:
$this->db->_protect_identifiers = false;
//resulting in SELECT foo FROM bar WHERE "foo" = 'data'

and my code will still break. I also have to disable something in each where clause I use there by not breaking my query.

I would highly suggest to the ci team to come up with a patch in the config so if I put something like

$protect_identifiers=FALSE

it globally turns them off (including where clauses) and you can turn them back on by using true as the switch in each active record call that needs it. That way pre-existing apps don't have to be adjusted and future apps can take advantage of the patch.


Messages In This Thread
globally disabling protect identifiers - by El Forum - 01-14-2010, 11:00 AM
globally disabling protect identifiers - by El Forum - 01-14-2010, 11:20 AM
globally disabling protect identifiers - by El Forum - 01-14-2010, 11:25 AM
globally disabling protect identifiers - by El Forum - 01-14-2010, 11:27 AM
globally disabling protect identifiers - by El Forum - 01-14-2010, 11:44 AM
globally disabling protect identifiers - by El Forum - 01-14-2010, 12:04 PM
globally disabling protect identifiers - by El Forum - 01-14-2010, 01:38 PM
globally disabling protect identifiers - by El Forum - 01-14-2010, 02:05 PM
globally disabling protect identifiers - by El Forum - 01-14-2010, 02:17 PM
globally disabling protect identifiers - by El Forum - 01-14-2010, 02:28 PM
globally disabling protect identifiers - by El Forum - 01-14-2010, 02:46 PM
globally disabling protect identifiers - by El Forum - 09-12-2012, 12:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB