Phalcon\Mvc\Model::getRelated does not seem to be working correctly with relations
Consider the following example, arguments passed to getRelated dose not seem to be working correctly, when working with namespaces in version 0.6.0 or 0.7.0:
public function getContact($arguments = null)
{
return this->getRelated('NAMESPACE', $arguments)
}
VERSION 0.6.0
Arguments passed to a self defined related function would not be used at all, the query set by phalcon would be of kind:
QUERY: [SELECT .. FROM .. WHERE primary_key = ID]
VERSION 0.7.0 Arguments passed to a self defined related function is now used, but the primary_key in the WHERE clause is nolonger present, resulting in all data matching $arguments being selected. QUERY: [SELECT .. FROM .. WHERE $arguments]
Work around in 0.7.0, added the primany key WHERE clause to the $arguments solves this problem, but makes the defined relation between the classes unnessary.
Phalcon\Mvc\Model::getRelated: https://phalcon-php-framework-documentation.readthedocs.org/en/0.7.0/api/Phalcon_Mvc_Model.html?highlight=getRelated
Namespaced relations: https://phalcon-php-framework-documentation.readthedocs.org/en/latest/reference/namespaces.html?highlight=getRelated
This works:
$x->getContact(array("conditions" => "xx"))
The new conditions will be appended to the relation conditions
Hi, sorry but the issue you're describing cannot be reproduced, please check out these unit-tests to understand the behavior of this functionality if that helps or provide a full test to reproduce the problem, thanks
https://github.com/phalcon/cphalcon/blob/0.7.0/unit-tests/ModelsRelationsTest.php