0
votes

_Hi Stackoverflow! I'm hoping for your help in clearing up a very unusual issue...

I've been using CakePHP to run a complex script involving thousands of fast-paced selects and inserts. After it runs for a few minutes, SQL errors are normally thrown out.

It's trying to build SQL queries using conditions from past finds. As in it take the "conditions" array from a completely different part of the system, and uses it as the WHERE clause of a simple find.

Any ideas on what can cause Cake's query builder to get confused?

1
What version of CakePHP are you using? - José Lorenzo Rodríguez
Catch the query that fails and see what the sql error is. First thing that comes to my mind is problem with ambiguous fields (like referring to id where the query has a join and both tables have that column) - ori
Looking at the query log was the first thing I tried. It's not an ambiguous field... it's a clear, unique set of conditions I'm using in an entirely different part of the system. The raw query starts as expected (the "fields" are correct), but after the WHERE it pulls in conditions used in a completely different method. It splices the two queries together, which causes the SQL error. - Harry
You don't have any finder queries set up in your model relationships do you? Or any other relations for that matter. - Barry Chapman
No Barry, I don't. They're fairly simple (empty) models. I'm hand-building the queries with the "conditions" and "joins" arrays. - Harry

1 Answers

0
votes

If you are doing several queries on the same request/process it is better to turn of the datasource method cache, because under certain circumstances it can lead to bad queries, while in most of cases it just speeds the app a bit:

ConnectionManager::getDataSource('default')->methodCache = false;