/** * Z $findBy prevede do $where v dibi formatu, $findBy vyprazdni. * @param BaseDibiCollection * @param DibiMapper * @param IDatabaseConventional * @param array reference * @param array reference * @param string * @param string * @see DataSourceCollection::getDataSource * @see DibiCollection::__toString * @see DibiCollection::join */ public static function dibiProcess(BaseDibiCollection $collection, DibiMapper $mapper, IDatabaseConventional $conventional, array &$where, array &$findBy, $tableAlias, $prefix = NULL) { foreach ($findBy as $tmp) { foreach ($tmp as $key => $value) { if ($prefix) { $key = $prefix . '->' . $key; } if ($join = $mapper->getJoinInfo($key)) { $collection->join($key); $key = $join->key; } else { $key = $conventional->formatEntityToStorage(array($key => NULL)); $key = $tableAlias . key($key); } if ($value instanceof IEntityCollection) { try { $value = $value->fetchPairs(NULL, 'id'); } catch (EntityNotPersistedException $e) { $value = $value->fetchAll(); } } if ($value instanceof IEntity) { $where[] = array('%n = %s', $key, isset($value->id) ? $value->id : NULL); // `= NULL` never be true } else { if (is_array($value)) { $tmp = array(); foreach ($value as $v) { if ($v instanceof IEntity) { if (!isset($v->id)) { continue; } $v = $v->id; } $tmp[] = $v; } $where[] = array('%n IN %in', $key, array_unique($tmp)); } else { if ($value === NULL) { $where[] = array('%n IS NULL', $key); } else { if ($value instanceof DateTime) { $where[] = array('%n = %t', $key, $value); } else { $where[] = array('%n = %s', $key, $value); } } } } } } $findBy = array(); }
/** * Discards the internal cache. * @param bool */ protected function release($count = false) { if ($count) { $this->count = NULL; } parent::release(); }
/** * Discards the internal cache. * @param bool */ protected function release($count = false) { if ($count) { $this->count = NULL; } $this->dataSource = NULL; parent::release(); }