Created
August 10, 2017 13:59
-
-
Save hmic/85669d2c45d0e0d06a1006f186e04637 to your computer and use it in GitHub Desktop.
hasMany association on cake2 with *very* custom finder example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AModel { | |
var $hasMany = array( | |
'Field' => array( | |
'className' => 'Field', | |
'foreignKey' => '', | |
'dependent' => false, | |
'conditions' => '', | |
'fields' => '', | |
'order' => '', | |
'limit' => '', | |
'offset' => '', | |
'exclusive' => '', | |
// {$__cakeID__$} | |
'finderQuery' => 'SELECT * FROM `fields` as `Field` WHERE `Field`.`id` IN (SELECT `field_id` FROM `category_fields` as `CategoryField` WHERE `category_id` = (SELECT `category_id` FROM `items` WHERE `items`.`id` = {$__cakeID__$})) ORDER BY `Field`.`order`', | |
'counterQuery' => 'SELECT COUNT(*) FROM `fields` as `Field` WHERE `Field`.`id` IN (SELECT `field_id` FROM `category_fields` as `CategoryField` WHERE `category_id` = (SELECT `category_id` FROM `items` WHERE `items`.`id` = {$__cakeID__$}))' | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment