lib/components/dataInterface/connectors/db/Model.php
public function getChildren()
    {
        if (is_null($this->_children)) {
            $children = [];
            // for this application, there is no distinction between hasOne and hasMany on the database level
            $hasMany = array_merge($this->meta->hasMany, $this->meta->hasOne);
            foreach ($hasMany as $r) {
                if (!isset($r['foreignModel'])) {
                    var_dump($r);
                    exit;
                    continue;
                }
                if (is_string($r['foreignModel'])
                    && (!isset($this->interface->foreignModels[$r['foreignModel']])
                    || !($r['foreignModel'] = $this->interface->foreignModels[$r['foreignModel']]))) {
                    continue;
                }
                $params = isset($r['params']) ? $r['params'] : [];
                $params[':foreignKeyId'] = $this->primaryKey;

                $where = isset($r['where']) ? $r['where'] : [];
                if (!empty($where)) {
                    $where = ['and', $where, $r['foreignKey'] . '=:foreignKeyId'];
                } else {
                    $where = $r['foreignKey'] . '=:foreignKeyId';
                }
                $query = [
                    'where' => $where,
                    'params' => $params,
                ];
                if (isset($r['join'])) {
                    $query['join'] = $r['join'];
                }
                $children[$r['foreignModel']->tableName] = $r['foreignModel']->findPrimaryKeys($query);
            }

            $this->_children = $children;
        }

        return $this->_children;
    }
public function getChildren()
    {
        if (is_null($this->_children)) {
            $children = [];
            // for this application, there is no distinction between hasOne and hasMany on the database level
            $hasMany = array_merge($this->meta->hasMany, $this->meta->hasOne);
            foreach ($hasMany as $r) {
                if (!isset($r['foreignModel'])) {
                    var_dump($r);
                    exit;
                    continue;
                }
                if (is_string($r['foreignModel'])
                    && (!isset($this->interface->foreignModels[$r['foreignModel']])
                    || !($r['foreignModel'] = $this->interface->foreignModels[$r['foreignModel']]))) {
                    continue;
                }
                $params = isset($r['params']) ? $r['params'] : [];
                $params[':foreignKeyId'] = $this->primaryKey;

                $where = isset($r['where']) ? $r['where'] : [];
                if (!empty($where)) {
                    $where = ['and', $where, $r['foreignKey'] . '=:foreignKeyId'];
                } else {
                    $where = $r['foreignKey'] . '=:foreignKeyId';
                }
                $query = [
                    'where' => $where,
                    'params' => $params,
                ];
                if (isset($r['join'])) {
                    $query['join'] = $r['join'];
                }
                $children[$r['foreignModel']->tableName] = $r['foreignModel']->findPrimaryKeys($query);
            }

            $this->_children = $children;
        }

        return $this->_children;
    }
public function getChildren ( ) { if ( is_null ( $ this -> _children ) ) { $ children = [ ] ; // for this application, there is no distinction between hasOne and hasMany on the database level $ hasMany = array_merge ( $ this -> meta -> hasMany , $ this -> meta -> hasOne ) ; foreach ( $ hasMany as $ r ) { if ( ! isset ( $ r [ 'foreignModel' ] ) ) { var_dump ( $ r ) ; exit ; continue ; } if ( is_string ( $ r [ 'foreignModel' ] ) && ( ! isset ( $ this -> interface -> foreignModels [ $ r [ 'foreignModel' ] ] ) || ! ( $ r [ 'foreignModel' ] = $ this -> interface -> foreignModels [ $ r [ 'foreignModel' ] ] ) ) ) { continue ; } $ params = isset ( $ r [ 'params' ] ) ? $ r [ 'params' ] : [ ] ; $ params [ ':foreignKeyId' ] = $ this -> primaryKey ; $ where = isset ( $ r [ 'where' ] ) ? $ r [ 'where' ] : [ ] ; if ( ! empty ( $ where ) ) { $ where = [ 'and' , $ where , $ r [ 'foreignKey' ] . '=:foreignKeyId' ] ; } else { $ where = $ r [ 'foreignKey' ] . '=:foreignKeyId' ; } $ query = [ 'where' => $ where , 'params' => $ params , ] ; if ( isset ( $ r [ 'join' ] ) ) { $ query [ 'join' ] = $ r [ 'join' ] ; } $ children [ $ r [ 'foreignModel' ] -> tableName ] = $ r [ 'foreignModel' ] -> findPrimaryKeys ( $ query ) ; } $ this -> _children = $ children ; } return $ this -> _children ; }
Get children.

@return array child objects for this model
Get children .