当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::getPrimaryKey方法代码示例

本文整理汇总了PHP中Entity::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getPrimaryKey方法的具体用法?PHP Entity::getPrimaryKey怎么用?PHP Entity::getPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity::getPrimaryKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processRecords

 /**
  * @param Entity $entity
  * @param array  $with
  * @param        $records
  * @param        $readOnly
  *
  * @return array
  */
 public function processRecords(Entity $entity, array $with, $records, $readOnly)
 {
     $pkField = $entity->getPrimaryKey();
     $objects = [];
     $currentKey = null;
     $object = null;
     $recordsToProcess = [];
     $relations = array_map([$entity, 'getRelation'], array_intersect($with, $entity->getRelationNames()));
     foreach ($records as $record) {
         //Extract columns that are relevant for the current metadata
         $key = $record[$pkField];
         if ($currentKey !== $key) {
             if ($object !== null) {
                 //Process and save the previous object
                 $this->processRelated($entity, $object, $readOnly, $recordsToProcess, $relations, $with);
                 $recordsToProcess = [];
                 $objects[$currentKey] = $object;
             }
             $currentKey = $key;
             $object = $this->createObject($entity, $record, $relations, $readOnly);
         }
         //Store the record to be processed for the related entities
         $recordsToProcess[] = $record;
     }
     if ($object !== null) {
         //Process and save the last object
         $this->processRelated($entity, $object, $readOnly, $recordsToProcess, $relations, $with);
         $objects[$key] = $object;
     }
     return $objects;
 }
开发者ID:bugadani,项目名称:orminy,代码行数:39,代码来源:ResultProcessor.php

示例2: generateIndexes

 private function generateIndexes(Entity $entity)
 {
     $indexes = array("\tPRIMARY KEY (`{$entity->getPrimaryKey()->getName()}`)");
     foreach ($entity->getFinders() as $finder) {
         $indexes[] = "\t" . $finder->getIndexDefinition();
     }
     return $indexes;
 }
开发者ID:aeberh,项目名称:php-movico,代码行数:8,代码来源:SqlGenerator.php

示例3: beforeSave

 /**
  * 注册entity
  */
 protected function beforeSave()
 {
     if (!$this->entityId) {
         $entity = new Entity();
         $entity->type = lcfirst(get_class($this));
         if ($entity->save()) {
             $this->entityId = $entity->getPrimaryKey();
             $this->_entity = $entity;
         }
     }
     return parent::beforeSave();
 }
开发者ID:stan5621,项目名称:jp_edu_online,代码行数:15,代码来源:EntityActiveRecord.php

示例4: load

 /**
  * @param Entity $entity
  * @param $tableName
  */
 public function load($entity, $tableName)
 {
     $primaryKey = $entity->getPrimaryKey();
     $primaryKeyName = $entity->getPrimaryKeyName();
     $criteria = array($primaryKeyName => $primaryKey);
     $where = $this->buildWhereClause($criteria);
     $sqlQuery = "SELECT * FROM " . $tableName . " WHERE " . $where;
     $stm = $this->database->prepare($sqlQuery);
     // Bind the where values
     $parameterIndex = 1;
     foreach ($criteria as $fieldName => &$value) {
         $stm->bindParam($parameterIndex, $value);
         $parameterIndex++;
     }
     $stm->execute();
     if ($stm->rowCount() > 0) {
         $row = $stm->fetch(PDO::FETCH_OBJ);
         $entity->init($row);
         $primaryKeyName = $entity->getPrimaryKeyName();
         $entity->setPrimaryKey($entity->object->{$primaryKeyName});
     }
 }
开发者ID:abelduarte,项目名称:PHP-EntityManager,代码行数:26,代码来源:EntityManager.class.php

示例5: getEntityByLastValueOfTabela

 public static function getEntityByLastValueOfTabela(Entity $objeto)
 {
     $primaryKey = $objeto->getPrimaryKey();
     $tabela = $objeto->getTableName();
     $sql = "select * from {$tabela} order by {$primaryKey} desc limit 1";
     $rs = self::returnDescription($sql, $objeto);
     return $rs;
 }
开发者ID:EduardoAlvarez,项目名称:retrospective,代码行数:8,代码来源:dbManager.php

示例6: generateRemove

 private function generateRemove(Entity $entity)
 {
     $pk = $entity->getPrimaryKey()->getName();
     return "\tpublic function remove(\${$pk}) {\n" . "\t\t\$this->findByPrimaryKey(\${$pk});\n" . "\t\t\$this->db->updateQuery(\"DELETE FROM \".self::TABLE.\" WHERE {$pk}='\".addslashes(\${$pk}).\"'\");\n" . "\t\tparent::\$dbCache->resetEntity('{$entity->getName()}');\n" . "\t\tparent::\$dbCache->resetSingle(\"{$entity->getName()}\", \${$pk});\n" . "\t}\n\n";
 }
开发者ID:aeberh,项目名称:php-movico,代码行数:5,代码来源:EntityPersistenceGenerator.php


注:本文中的Entity::getPrimaryKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。