Left join count results differ between 1.3 and 2.0

Simply it may be a bug or a feature. In 1.3 left join returns f.e 2 objects in a single result object. In 2.0 it does too. But in 1.3 i have number 2 when i use count($model), and number 1 in 2.0. I'll find a way to deal with it but just wanted to say that something like that happened - my volt template check this number to "decide" what to do.



5.1k
edited May '15

I did in volt file something temporary, which base on an assumption that if a result has two elements i am sure in this case it is two part result, i mean i don't have less than 3 properties/columns in a db table so i know this is a two part result not one.

        {% for subitem in item %}{# item|length (or count in PHP code)) doesn't work properly in phalcon 2.0.1 #}
            {% if loop.index == 1 %}{% set items_length=1 %}{% endif %}
            {% if loop.index == 2 %}{% set items_length=2 %}{% endif %}
            {% if loop.index == 3 %}{% set items_length=1 %}{% endif %}
        {% endfor %}

Can you please post the models/tables and JOIN you're doing to make this happen?



5.1k
edited May '15

Example code first (php volt count/|length alike):

echo $phql;

$categories = $this->modelsManager->executeQuery($phql);

echo "<br />A".count($categories)."A";ob_flush();

foreach ($categories as $category) {
    echo "<br />B".count($category)."B";ob_flush();
    echo "@@".$category->icd10codesdictionary->id."@@".$category->icd10codesdictionarytranslations->id."@@";
}

Produces in 1.3:

SELECT Icd10codesdictionary.*, Icd10codesdictionarytranslations.* FROM Icd10codesdictionary LEFT JOIN Icd10codesdictionarytranslations ON Icd10codesdictionary.id=Icd10codesdictionarytranslations.icd10_id
A31A
B2B@@1@@16@@
B2B@@1@@17@@
B2B@@1@@15@@
B2B@@2@@18@@
........ and so on

and in 2.0

SELECT Icd10codesdictionary.*, Icd10codesdictionarytranslations.* FROM Icd10codesdictionary LEFT JOIN Icd10codesdictionarytranslations ON Icd10codesdictionary.id=Icd10codesdictionarytranslations.icd10_id
A31A
B1B@@1@@16@@
B1B@@1@@17@@
B1B@@1@@15@@
B1B@@2@@18@@
... and so on

And as i

Db models Icd10codesdictionary
    public $id;
    public $icd10_code;
    public $readable_name;
    public $desc;
    public $data;
    public $language_id;
    public $is_active;
    public $code_type_id;
    public $average_duration;

Icd10codesdictionarytranslations    
    public $id;
    public $icd10_id;
    public $language_id;
    public $icd10_code;
    public $readable_name;
    public $desc;
    public $data;
    public $is_active;



5.1k
edited May '15

Here there was a wrong reply. I removed contents not to confuse. Sorry.