{"action":"created","issue":{"url":"https://api.github.com/repos/koala-framework/koala-framework/issues/379","labels_url":"https://api.github.com/repos/koala-framework/koala-framework/issues/379/labels{/name}","comments_url":"https://api.github.com/repos/koala-framework/koala-framework/issues/379/comments","events_url":"https://api.github.com/repos/koala-framework/koala-framework/issues/379/events","html_url":"https://github.com/koala-framework/koala-framework/issues/379","id":94234642,"number":379,"title":"Problem with ORM dependencies (select in select)","user":{"login":"Sogl","id":7556290,"avatar_url":"https://avatars.githubusercontent.com/u/7556290?v=3","gravatar_id":"","url":"https://api.github.com/users/Sogl","html_url":"https://github.com/Sogl","followers_url":"https://api.github.com/users/Sogl/followers","following_url":"https://api.github.com/users/Sogl/following{/other_user}","gists_url":"https://api.github.com/users/Sogl/gists{/gist_id}","starred_url":"https://api.github.com/users/Sogl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sogl/subscriptions","organizations_url":"https://api.github.com/users/Sogl/orgs","repos_url":"https://api.github.com/users/Sogl/repos","events_url":"https://api.github.com/users/Sogl/events{/privacy}","received_events_url":"https://api.github.com/users/Sogl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-07-10T07:12:16Z","updated_at":"2015-07-16T10:11:19Z","closed_at":null,"body":"Hi!\r\n\r\nI'm trying to use JOIN with other table.\r\nMy php code:\r\n```php\r\n$s = new Kwf_Model_Select();\r\n$s->where(new Kwf_Model_Select_Expr_Sql('TypeName = \\'Вертолёт\\' AND suTypeName = \\'Много\\''));\r\n$flightresultsSelect = $flightresultsModel->select()->where(new Kwf_Model_Select_Expr_Sql('ownerId = ' . $employee->id\r\n                                                                                   .' AND flightDate <= \\'' . $endDateMonth1->format('Y-m-d')\r\n                                                                                   .'\\' AND typeName = \\'Налет общий\\'\r\n                                                                                   AND flightTime <> \\'00:00:00\\''))\r\n                                                                                   ->where(new Kwf_Model_Select_Expr_Child_Contains('Wsmodels', $s));\r\n$flightresultsRows = $flightresultsModel->getRows($flightresultsSelect);\r\n```\r\n\r\nResult sql query:\r\n```sql\r\nSELECT `flightResults`.* FROM `flightResults` WHERE ((ownerId = 51 AND flightDate <= '2015-06-30' AND typeName = 'Налет общий' AND flightTime <> '00:00:00')) \r\nAND (flightResults.id IN (SELECT `wsModels`.`id` FROM `wsModels` WHERE ((TypeName = 'Вертолёт' AND suTypeName = 'Много'))))\r\n```\r\n\r\nBut I want to use `flightResults.planeId` in query, not `flightResults.id`.\r\nHow to do that? \r\n\r\nMy models.\r\nFlightresults.php:\r\n```php\r\n<?php\r\nclass Flightresults extends Kwf_Model_Db\r\n{\r\n    protected $_table = 'flightResults';\r\n    protected $_referenceMap = array(\r\n        'Plane' => array(\r\n            'column'           => 'planeId',\r\n            'refModelClass'     => 'Wsmodels',\r\n        )\r\n    );\r\n\r\n    protected $_dependentModels = array(\r\n        'Wsmodels' => 'Wsmodels'\r\n    );\r\n}\r\n```\r\n\r\nWsmodels.php:\r\n```php\r\n<?php\r\nclass Wsmodels extends Kwf_Model_Db\r\n{\r\n    protected $_table = 'wsModels';\r\n    protected $_toStringField = 'Name';\r\n\r\n    protected $_referenceMap = array(\r\n        'Flightresult' => array(\r\n            'column'           => 'id',\r\n            'refModelClass'     => 'Flightresults',\r\n        )\r\n    );\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/koala-framework/koala-framework/issues/comments/121916674","html_url":"https://github.com/koala-framework/koala-framework/issues/379#issuecomment-121916674","issue_url":"https://api.github.com/repos/koala-framework/koala-framework/issues/379","id":121916674,"user":{"login":"nsams","id":50764,"avatar_url":"https://avatars.githubusercontent.com/u/50764?v=3","gravatar_id":"","url":"https://api.github.com/users/nsams","html_url":"https://github.com/nsams","followers_url":"https://api.github.com/users/nsams/followers","following_url":"https://api.github.com/users/nsams/following{/other_user}","gists_url":"https://api.github.com/users/nsams/gists{/gist_id}","starred_url":"https://api.github.com/users/nsams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsams/subscriptions","organizations_url":"https://api.github.com/users/nsams/orgs","repos_url":"https://api.github.com/users/nsams/repos","events_url":"https://api.github.com/users/nsams/events{/privacy}","received_events_url":"https://api.github.com/users/nsams/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T10:11:19Z","updated_at":"2015-07-16T10:11:19Z","body":"How is flightResults associated with wsModels? Please post the relevant foreign keys."}}