本文整理汇总了PHP中Criteria::size方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::size方法的具体用法?PHP Criteria::size怎么用?PHP Criteria::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
protected function update($connection = null)
{
if (!isset($connection)) {
$connection = QubitTransactionFilter::getConnection(QubitOaiHarvest::DATABASE_NAME);
}
$offset = 0;
foreach ($this->tables as $table) {
$criteria = new Criteria();
$selectCriteria = new Criteria();
foreach ($table->getColumns() as $column) {
if (!array_key_exists($column->getPhpName(), $this->values)) {
if ('updatedAt' == $column->getPhpName()) {
$this->values['updatedAt'] = new DateTime();
}
}
if (array_key_exists($column->getPhpName(), $this->values)) {
if ('serialNumber' == $column->getPhpName()) {
$selectCriteria->add($column->getFullyQualifiedName(), $this->values[$column->getPhpName()]++);
}
$criteria->add($column->getFullyQualifiedName(), $this->param($column));
}
if ($column->isPrimaryKey()) {
$selectCriteria->add($column->getFullyQualifiedName(), $this->keys[$column->getPhpName()]);
}
$offset++;
}
if (0 < $criteria->size()) {
BasePeer::doUpdate($selectCriteria, $criteria, $connection);
}
}
return $this;
}
示例2: equals
/**
* This method checks another Criteria to see if they contain
* the same attributes and hashtable entries.
*
* @param Criteria|null $crit
* @return boolean
*/
public function equals($crit)
{
if ($crit === null || !$crit instanceof Criteria) {
return false;
} elseif ($this === $crit) {
return true;
} elseif ($this->size() === $crit->size()) {
// Important: nested criterion objects are checked
$criteria = $crit;
// alias
if ($this->offset === $criteria->getOffset() && $this->limit === $criteria->getLimit() && $this->ignoreCase === $criteria->isIgnoreCase() && $this->singleRecord === $criteria->isSingleRecord() && $this->dbName === $criteria->getDbName() && $this->selectModifiers === $criteria->getSelectModifiers() && $this->selectColumns === $criteria->getSelectColumns() && $this->asColumns === $criteria->getAsColumns() && $this->orderByColumns === $criteria->getOrderByColumns() && $this->groupByColumns === $criteria->getGroupByColumns() && $this->aliases === $criteria->getAliases()) {
foreach ($criteria->keys() as $key) {
if ($this->containsKey($key)) {
$a = $this->getCriterion($key);
$b = $criteria->getCriterion($key);
if (!$a->equals($b)) {
return false;
}
} else {
return false;
}
}
$joins = $criteria->getJoins();
if (count($joins) != count($this->joins)) {
return false;
}
foreach ($joins as $key => $join) {
if (!$join->equals($this->joins[$key])) {
return false;
}
}
return true;
} else {
return false;
}
}
return false;
}
示例3: getNNRelatedChangeLog
/**
* This methods inspects the columns of the object's table and if one of them if a foreign key,
* it returns the change log of the referenced object IF it points to the specified object (parameter).
*
* @param mixed $object
* @param date $from_date
* @param transformToAdapters
*
* @return Array of ncChangeLogEntry
*/
public function getNNRelatedChangeLog($object, $from_date = null, $transformToAdapters = true)
{
$relatedChangeLog = array();
$relatedObjects = array();
if (!is_null($object)) {
// Obtain object's information
$object_class = get_class($object);
$peer = constant($object_class . '::PEER');
// Get all tableMaps and make the queries to retrieve all object instances that reference the object!!!
ncClassFinder::getInstance()->reloadClasses();
foreach (ncClassFinder::getInstance()->getPeerClasses() as $class => $path) {
if ($class != get_class($object) && class_exists($class) && method_exists($class, 'getTableMap')) {
$criteria = new Criteria();
$tableMap = call_user_func(array($class, 'getTableMap'));
foreach ($tableMap->getColumns() as $c) {
if ($c->isForeignKey()) {
$method = 'get' . $c->getPhpName();
$relatedTableName = $c->getRelatedTableName();
$relatedColName = $c->getRelatedColumnName();
$relatedPeerClass = ncClassFinder::getInstance()->findPeerClassName($relatedTableName);
$relatedClass = ncClassFinder::getInstance()->findClassName($relatedTableName, $relatedPeerClass);
// Traverse all collumns. If any has as its `relatedClass` the class of $object, make a
// Criteria object to fetch every related object.
if ($relatedClass == get_class($object)) {
$criterion = $criteria->getNewCriterion(constant($class . '::' . $c->getName()), $object->getPrimaryKey());
$criteria->addOr($criterion);
}
}
}
if ($criteria->size() > 0) {
$relatedObjects[$class] = call_user_func(array($class, 'doSelect'), $criteria);
}
}
}
// Get every object's change log
foreach ($relatedObjects as $tableName => $objects) {
foreach ($objects as $o) {
$criteria = new Criteria();
if (!is_null($from_date)) {
$criteria->add(ncChangeLogEntryPeer::CREATED_AT, $from_date, Criteria::GREATER_THAN);
}
if (sfMixer::getCallable('Base' . get_class($o) . ':getChangeLog') && count($changes = $o->getChangeLog($criteria)) > 0) {
if (method_exists($o, '__toString')) {
$relatedChangeLog[$tableName][strval($o)] = $changes;
} else {
$relatedChangeLog[$tableName][$o->getPrimaryKey()] = $changes;
}
}
}
}
}
return $relatedChangeLog;
}
示例4: equals
/**
* This method checks another Criteria to see if they contain
* the same attributes and hashtable entries.
*
* @param Criteria $crit
*
* @return boolean
*/
public function equals($crit)
{
$isEquiv = false;
if ($crit === null || !($crit instanceof Criteria)) {
$isEquiv = false;
} elseif ($this === $crit) {
$isEquiv = true;
} elseif ($this->size() === $crit->size()) {
// Important: nested criterion objects are checked
$criteria = $crit; // alias
if ($this->offset === $criteria->getOffset()
&& $this->limit === $criteria->getLimit()
&& $this->ignoreCase === $criteria->isIgnoreCase()
&& $this->singleRecord === $criteria->isSingleRecord()
&& $this->dbName === $criteria->getDbName()
&& $this->selectModifiers === $criteria->getSelectModifiers()
&& $this->selectColumns === $criteria->getSelectColumns()
&& $this->orderByColumns === $criteria->getOrderByColumns()
&& $this->groupByColumns === $criteria->getGroupByColumns()
)
{
$isEquiv = true;
foreach($criteria->keys() as $key) {
if ($this->containsKey($key)) {
$a = $this->getCriterion($key);
$b = $criteria->getCriterion($key);
if (!$a->equals($b)) {
$isEquiv = false;
break;
}
} else {
$isEquiv = false;
break;
}
}
}
}
return $isEquiv;
}
示例5: update
protected function update($connection = null)
{
// Update nested set keys only if parent id has changed
if (isset($this->values['parentId'])) {
// Get the "original" parentId before any updates
$offset = 0;
$originalParentId = null;
foreach ($this->tables as $table) {
foreach ($table->getColumns() as $column) {
if ('parentId' == $column->getPhpName()) {
$originalParentId = $this->row[$offset];
break;
}
$offset++;
}
}
// If updated value of parentId is different then original value,
// update the nested set
if ($originalParentId != $this->values['parentId']) {
$this->updateNestedSet($connection);
}
}
if (!isset($connection)) {
$connection = QubitTransactionFilter::getConnection(QubitMenu::DATABASE_NAME);
}
$offset = 0;
foreach ($this->tables as $table) {
$criteria = new Criteria();
$selectCriteria = new Criteria();
foreach ($table->getColumns() as $column) {
if (!array_key_exists($column->getPhpName(), $this->values)) {
if ('updatedAt' == $column->getPhpName()) {
$this->values['updatedAt'] = new DateTime();
}
}
if (array_key_exists($column->getPhpName(), $this->values)) {
if ('serialNumber' == $column->getPhpName()) {
$selectCriteria->add($column->getFullyQualifiedName(), $this->values[$column->getPhpName()]++);
}
$criteria->add($column->getFullyQualifiedName(), $this->param($column));
}
if ($column->isPrimaryKey()) {
$selectCriteria->add($column->getFullyQualifiedName(), $this->keys[$column->getPhpName()]);
}
$offset++;
}
if (0 < $criteria->size()) {
BasePeer::doUpdate($selectCriteria, $criteria, $connection);
}
}
return $this;
}