Example #1
0
 /**
  * Query the records on which the UPDATE/DELETE operation well be done
  *
  * @param \Phalcon\Mvc\Model $model
  * @param array $intermediate
  * @param array $bindParams
  * @param array $bindTypes
  * @return \Phalcon\Mvc\Model\ResultsetInterface
  */
 protected function _getRelatedRecords(Model $model, array $intermediate, array $bindParams, array $bindTypes)
 {
     $selectColumns = array(array(array('type' => 'object', 'model' => get_class($model), 'column' => $model->getSource())));
     //Instead of creating a PHQL string statement, we manually create the IR representation
     $selectIr = array('columns' => $selectColumns, 'models' => $intermediate['models'], 'tables' => $intermediate['tables']);
     //Check if a WHERE clause was especified
     if (isset($intermediate['where']) === true) {
         $selectIr['where'] = $intermediate['where'];
     }
     if (isset($intermediate['limit']) === true) {
         $selectIr['limit'] = $intermediate['limit'];
     }
     //We create another Phalcon\Mvc\Model\Query to get the related records
     $query = new Query();
     $query->setDi($this->_dependencyInjector);
     $query->setType(309);
     $query->setIntermediate($selectIr);
     return $query->execute($bindParams, $bindTypes);
 }