Hi, sorry for posting this here, but I didin't find an answer for this behavior anywhere. This may be DB related, but again, I couldn't find a clue.
I have the following code inside a while
block, where $row
is an associative array containing the data to be inserted/updated:
if(isset($row['ext_id'])) {
$entity = Robot::findFirst("ext_id='{$row['ext_id']}'");
if(!$entity){
$entity = new Robot();
}
$entity->save($row);
}
The problem is that if I already have a row in the DB with ext_id
column ending in 'eu' (e.g. ext_id=ABCeu
), when I try to insert the row ending in 'fT' (e.g. ext_id="ABCfT"
) it overwrites that one. Someway, Phalcon is retrieving both as they are the same. I'm telling this because every time I do
$entity = $model::findFirst("ext_id='ABCfT'");
I get
echo $entity->ext_id; //prints 'ABCeu'
There're 3 things I have to make notice of:
-
The
ext_id
column usesutf8_bin
collation because of its case-sensitive capabilities, while the whole database usesutf8_general_ci
. I've tried changing the column collation and the results are the same. -
This only happens on Phalcon. If I try to run the query (
SELECT * FROM robot WHERE ext_id="ABCfT"
) it returns no results. - This one is not the only case. This is actually a pattern. Every time I use a substring formed by 'f' plus a uppercase letter (e.g. 'T'), it will get the result as if it was 'e' plus the lowercase letter that follows the uppercase one (in this case 'u')
Hope I had made myself clear. Thanks in advance.
Ps.: I'm using Phalcon 1.3.2 / PHP 5.4.16 / MySQL 5.5.37