cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

Error with searching in Phalcon_Model_Query

Open Hockeychap opened this issue 14 years ago • 3 comments

Hi,

Have been testing the functionality of the Phalcon and the devtools package. Have run the scaffold command against a very simple mysql order table (orderid int, customerid int, orderdate date).

Using the search screen the search works fine for the integer fields, but not the date field. It looks like Phalcon_Model_Query is not putting quotes around the like statement (error sql attached below).

SELECT orderid, customerid, orderdate FROM justin_testing.orders WHERE customerid = 1 AND orderdate LIKE %2012-06% ORDER BY orderid

The order table appears tohave been created correctly in the model with the orderdate field modeled as a string.

Cheers Justin

Hockeychap avatar Jun 25 '12 09:06 Hockeychap

Update: I've fixed this on my local copy by added a pair of single quotes into line 361 model/query.c so that it now reads :

PHALCON_CONCAT_SVS(r15, "'%", value, "%'");

rather than

PHALCON_CONCAT_SVS(r15, "%", value, "%");

Cheers Justin

Hockeychap avatar Jun 25 '12 12:06 Hockeychap

Thanks Justin!, we'll add this to 0.4.2 :)

ghost avatar Jun 25 '12 15:06 ghost

Hi Justin, 0.4.2 is now available, thanks for reporting this!

ghost avatar Jun 26 '12 17:06 ghost