Welcome Guest, Not a member yet? Register   Sign In
Database error after upgrading to CI 1.7
#3

[eluser]Sergi Ortega [TEAMVALLES][/eluser]
Hello,

I had the same problem two days ago when actualized CI to 1.7.X

DB Class in CI 1.6.X (Active Record) don't escape automatically queries.

Example:

Code:
$this->db->select("*,DATE_FORMAT(created,'%d-%m-%Y %h:%m:%s') as created_format")->from("foo");
This works well in 1.6.X but NOT in 1.7.X !!

The problem is that CI 1.7.X automatically escapes strange chars for preventing SQL Injection such as ( and ' and %.
CI 1.7.X now has a second parameter in SELECT method (ESCAPE OR NOT / TRUE, FALSE), by default TRUE.

So in CI 1.7.X the same query is like this:

Code:
$this->db->select("*,DATE_FORMAT(created,'%d-%m-%Y %h:%m:%s',FALSE) as created_format")->from("foo");
See second parameter (,FALSE) in SELECT method

In 1.7.X if you're programming basic queries like:

Code:
$this->db->select("*")->from("foo");

Second parameter (ESCAPE OR NOT) don't to be passed due Select query * don't need to be escaped because haven't any strange injection chars.

Good Luck!


Messages In This Thread
Database error after upgrading to CI 1.7 - by El Forum - 11-07-2008, 10:35 PM
Database error after upgrading to CI 1.7 - by El Forum - 11-07-2008, 11:15 PM
Database error after upgrading to CI 1.7 - by El Forum - 11-08-2008, 05:46 AM
Database error after upgrading to CI 1.7 - by El Forum - 11-08-2008, 05:56 AM
Database error after upgrading to CI 1.7 - by El Forum - 11-08-2008, 06:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB