• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP PropelQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     BookstoreDataPopulator::populate($this->con);
     Propel::disableInstancePooling();
     $this->books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
 }
开发者ID:halfer,项目名称:Meshing,代码行数:7,代码来源:PropelOnDemandCollectionTest.php


示例2: getChoices

 /**
  * Returns the choices associated to the model.
  *
  * @return array An array of choices
  */
 public function getChoices()
 {
     $choices = array();
     if (false !== $this->getOption('add_empty')) {
         $choices[''] = true === $this->getOption('add_empty') ? '' : $this->getOption('add_empty');
     }
     $criteria = PropelQuery::from($this->getOption('model'));
     if ($this->getOption('criteria')) {
         $criteria->mergeWith($this->getOption('criteria'));
     }
     foreach ($this->getOption('query_methods') as $methodName => $methodParams) {
         if (is_array($methodParams)) {
             call_user_func_array(array($criteria, $methodName), $methodParams);
         } else {
             $criteria->{$methodParams}();
         }
     }
     if ($order = $this->getOption('order_by')) {
         $criteria->orderBy($order[0], $order[1]);
     }
     $objects = $criteria->find($this->getOption('connection'));
     $methodKey = $this->getOption('key_method');
     if (!method_exists($this->getOption('model'), $methodKey)) {
         throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $methodKey, __CLASS__));
     }
     $methodValue = $this->getOption('method');
     if (!method_exists($this->getOption('model'), $methodValue)) {
         throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $methodValue, __CLASS__));
     }
     foreach ($objects as $object) {
         $choices[$object->{$methodKey}()] = $object->{$methodValue}();
     }
     return $choices;
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:39,代码来源:sfWidgetFormPropelChoice.class.php


示例3: testFilterById

 /**
  * testFilterById
  *
  * Various test for filterById functions
  * Id's are autoincrement so we have to use a Select to get current ID's
  *
  */
 public function testFilterById()
 {
     // find by single id
     $book = PropelQuery::from('Book b')->where('b.Title like ?', 'Don%')->orderBy('b.ISBN', 'desc')->findOne();
     $c = BookQuery::create()->filterById($book->getId());
     $book2 = $c->findOne();
     $this->assertTrue($book2 instanceof Book);
     $this->assertEquals('Don Juan', $book2->getTitle());
     //find range
     $booksAll = PropelQuery::from('Book b')->orderBy('b.ID', 'asc')->find();
     $booksIn = BookQuery::create()->filterById(array($booksAll[1]->getId(), $booksAll[2]->getId()))->find();
     $this->assertTrue($booksIn[0] == $booksAll[1]);
     $this->assertTrue($booksIn[1] == $booksAll[2]);
     // filter by min value with greater equal
     $booksIn = null;
     $booksIn = BookQuery::create()->filterById(array('min' => $booksAll[2]->getId()))->find();
     $this->assertTrue($booksIn[1] == $booksAll[3]);
     // filter by max value with less equal
     $booksIn = null;
     $booksIn = BookQuery::create()->filterById(array('max' => $booksAll[1]->getId()))->find();
     $this->assertTrue($booksIn[1] == $booksAll[1]);
     // check backwards compatibility:
     // SELECT  FROM `book` WHERE book.id IN (:p1,:p2)
     // must be the same as
     // SELECT  FROM `book` WHERE (book.id>=:p1 AND book.id<=:p2)
     $minMax = BookQuery::create()->filterById(array('min' => $booksAll[1]->getId(), 'max' => $booksAll[2]->getId()))->find();
     $In = BookQuery::create()->filterById(array($booksAll[1]->getId(), $booksAll[2]->getId()))->find();
     $this->assertTrue($minMax[0] === $In[0]);
     $this->assertTrue(count($minMax->getData()) === count($In->getData()));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:37,代码来源:PropelQueryTest.php


示例4: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($value)
 {
     $criteria = PropelQuery::from($this->getOption('model'));
     if ($this->getOption('criteria')) {
         $criteria->mergeWith($this->getOption('criteria'));
     }
     foreach ($this->getOption('query_methods') as $method) {
         $criteria->{$method}();
     }
     if ($this->getOption('multiple')) {
         if (!is_array($value)) {
             $value = array($value);
         }
         $count = count($value);
         if ($this->hasOption('min') && $count < $this->getOption('min')) {
             throw new sfValidatorError($this, 'min', array('count' => $count, 'min' => $this->getOption('min')));
         }
         if ($this->hasOption('max') && $count > $this->getOption('max')) {
             throw new sfValidatorError($this, 'max', array('count' => $count, 'max' => $this->getOption('max')));
         }
         $criteria->addAnd($this->getColumn(), $value, Criteria::IN);
         $dbcount = $criteria->count($this->getOption('connection'));
         if ($dbcount != $count) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
     } else {
         $criteria->addAnd($this->getColumn(), $value);
         $dbcount = $criteria->count($this->getOption('connection'));
         if (0 === $dbcount) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
     }
     return $value;
 }
开发者ID:sanemat,项目名称:bllik,代码行数:37,代码来源:sfValidatorPropelChoice.class.php


示例5: getSelection

 /**
  * @return \BaseObject|null
  * @throws \PropelException
  */
 public function getSelection()
 {
     $pk = isset($this['id']) ? json_decode($this['id'], true) : null;
     if ($pk && $this->parent instanceof AbstractBackend) {
         return \PropelQuery::from($this->parent->getModelClass())->findPk($pk);
     }
     return null;
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:12,代码来源:AbstractBackend.php


示例6: testQuery

 public function testQuery()
 {
     BookstoreDataPopulator::depopulate();
     BookstoreDataPopulator::populate();
     $book = PropelQuery::from('Book b')->where('b.Title like ?', 'Don%')->orderBy('b.ISBN', 'desc')->findOne();
     $this->assertTrue($book instanceof Book);
     $this->assertEquals('Don Juan', $book->getTitle());
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:PropelQueryTest.php


示例7: createIndex

 public static function createIndex($class)
 {
   $index = self::getLuceneIndex($class);
   $objects = PropelQuery::from($class)->find();
   foreach ($objects as $object)
   {
     $object->updateLuceneIndex($index);
   }
 }
开发者ID:nibsirahsieu,项目名称:sfPropelLuceneableBehaviorPlugin,代码行数:9,代码来源:sfLuceneableToolkit.class.php


示例8: __construct

 public function __construct($className, array $options = array(), \ModelCriteria $query = null)
 {
     $this->className = $className;
     $this->options = array_replace_recursive($this->options, $options);
     if (!$query) {
         $query = \PropelQuery::from($this->className);
     }
     $this->query = $query;
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:9,代码来源:ModelTranslation.php


示例9: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method (this validator can only be used as a post validator).');
     }
     if (!is_array($this->getOption('column'))) {
         $this->setOption('column', array($this->getOption('column')));
     }
     if (!is_array($field = $this->getOption('field'))) {
         $this->setOption('field', $field ? array($field) : array());
     }
     $fields = $this->getOption('field');
     $criteria = PropelQuery::from($this->getOption('model'));
     foreach ((array) $this->getOption('query_methods') as $methodName => $methodParams) {
         if (is_array($methodParams)) {
             $criteria = call_user_func_array(array($criteria, $methodName), $methodParams);
         } else {
             $criteria = $criteria->{$methodParams}();
         }
     }
     if ($this->getOption('allow_null_uniques')) {
         $tableMap = call_user_func(array($this->getOption('model') . 'Peer', 'getTableMap'));
         $nullColsCount = 0;
     }
     foreach ($this->getOption('column') as $i => $column) {
         $name = isset($fields[$i]) ? $fields[$i] : $column;
         if (!array_key_exists($name, $values)) {
             // one of the column has been removed from the form
             return $values;
         }
         $colName = call_user_func(array(constant($this->getOption('model') . '::PEER'), 'translateFieldName'), $column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
         // handle null unique indexes
         if ($this->getOption('allow_null_uniques') && null === $values[$name] && !$tableMap->getColumn($colName)->isNotNull()) {
             $nullColsCount++;
             continue;
         }
         $criteria->add($colName, $values[$name]);
     }
     if ($this->getOption('allow_null_uniques') && $nullColsCount == count($this->getOption('column'))) {
         // all columns for checking were both empty and null unique
         $object = null;
     } else {
         // perform query for normal unique check
         $object = $criteria->findOne($this->getOption('connection'));
     }
     // if no object or if we're updating the object, it's ok
     if (null === $object || $this->isUpdate($object, $values)) {
         return $values;
     }
     $error = new sfValidatorError($this, 'invalid', array('column' => implode(', ', $this->getOption('column'))));
     if ($this->getOption('throw_global_error')) {
         throw $error;
     }
     $columns = $this->getOption('column');
     throw new sfValidatorErrorSchema($this, array($columns[0] => $error));
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:59,代码来源:sfValidatorPropelUnique.class.php


示例10: render

 public function render(Curry_Backend $backend, array $params)
 {
     $modelClass = $this->modelForm->getModelClass();
     $item = $this->getSelection($params);
     if (!isset($item)) {
         $item = new $modelClass();
         $relatedItem = $this->getParentSelection($params);
         if ($relatedItem) {
             $relations = PropelQuery::from($modelClass)->getTableMap()->getRelations();
             foreach ($relations as $relation) {
                 if ($relation->getRightTable()->getPhpName() == get_class($relatedItem) && in_array($relation->getType(), array(RelationMap::MANY_TO_ONE))) {
                     $item->{'set' . $relation->getName()}($relatedItem);
                 }
             }
         }
     }
     $form = clone $this->modelForm;
     $form->setOptions(array('method' => 'post', 'action' => (string) url('', $params)));
     $buttons = array('save');
     $form->addElement('submit', 'save', array('label' => 'Save'));
     if (!$item->isNew() && $this->parentView instanceof Curry_ModelView_List && $this->parentView->hasAction('delete')) {
         $form->addElement('submit', 'delete', array('label' => 'Delete', 'class' => 'btn btn-danger', 'onclick' => "return confirm('Do you really want to delete this item? This cannot be undone.');"));
         $buttons[] = 'delete';
     }
     $form->addDisplayGroup($buttons, 'save_group', array('class' => 'horizontal-group'));
     $form->fillForm($item);
     if (isPost() && $form->isValid($_POST)) {
         if ($form->delete && $form->delete->isChecked()) {
             $backend->createModelUpdateEvent($modelClass, $item->getPrimaryKey(), 'delete');
             $item->delete();
             if ($item instanceof Curry_ISearchable) {
                 Curry_Backend_Indexer::removeItem($item);
             }
             $backend->addMainContent('<p>The item has been deleted.</p>');
             return;
         }
         $form->fillModel($item);
         $this->triggerCallback($this->preSave, $item, $form);
         $item->save();
         $this->triggerCallback($this->postSave, $item, $form);
         $form->fillForm($item);
         $backend->createModelUpdateEvent($modelClass, $item->getPrimaryKey(), 'update');
         if ($item instanceof Curry_ISearchable) {
             Curry_Backend_Indexer::updateItem($item);
         }
         if (isAjax()) {
             return '';
         }
     }
     $this->triggerCallback($this->preRender, $item, $form);
     $backend->addMainContent($form);
 }
开发者ID:varvanin,项目名称:currycms,代码行数:52,代码来源:Form.php


示例11: show

 public function show(Request $request)
 {
     $modelClass = $this->modelForm->getModelClass();
     $item = $this->getSelection();
     if (!isset($item) || !$item instanceof $modelClass) {
         $item = new $modelClass();
         $relatedItem = $this->parent instanceof AbstractBackend ? $this->parent->getSelection() : null;
         if ($relatedItem) {
             $relations = \PropelQuery::from($modelClass)->getTableMap()->getRelations();
             foreach ($relations as $relation) {
                 if ($relation->getRightTable()->getPhpName() == get_class($relatedItem) && in_array($relation->getType(), array(\RelationMap::MANY_TO_ONE))) {
                     $item->{'set' . $relation->getName()}($relatedItem);
                 }
             }
         }
     }
     $form = clone $this->modelForm;
     $buttons = array('save');
     $form->addField('save', array('type' => 'submit', 'label' => 'Save', 'class' => 'btn btn-primary'));
     if (!$item->isNew() && $this->parent instanceof ListView && $this->parent->hasAction('delete')) {
         $form->addField('delete', array('type' => 'submit', 'label' => 'Delete', 'class' => 'btn btn-danger', 'onclick' => "return confirm('Do you really want to delete this item? This cannot be undone.');"));
         $buttons[] = 'delete';
     }
     //$form->addDisplayGroup($buttons, 'save_group', array('class' => 'horizontal-group'));
     $form->fillForm($item);
     if ($request->isMethod('POST') && $form->isValid($request->request->all())) {
         if ($form->delete && $form->delete->isChecked()) {
             //$this->createModelUpdateEvent($modelClass, $item->getPrimaryKey(), 'delete');
             $item->delete();
             if ($item instanceof \Curry_ISearchable) {
                 \Curry_Backend_Indexer::removeItem($item);
             }
             $this->addMainContent('<p>The item has been deleted.</p>');
             return parent::render();
         }
         $form->fillModel($item);
         $this->triggerCallback($this->preSave, $item, $form);
         $item->save();
         $this->triggerCallback($this->postSave, $item, $form);
         $form->fillForm($item);
         //$this->createModelUpdateEvent($modelClass, $item->getPrimaryKey(), 'update');
         if ($item instanceof \Curry_ISearchable) {
             \Curry_Backend_Indexer::updateItem($item);
         }
         if ($request->isXmlHttpRequest()) {
             return \Symfony\Component\HttpFoundation\Response::create('');
         }
     }
     $this->triggerCallback($this->preRender, $item, $form);
     $this->addMainContent($form);
     return parent::render();
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:52,代码来源:Form.php


示例12: testInstancePoolingReenabled

 public function testInstancePoolingReenabled()
 {
     Propel::enableInstancePooling();
     $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con);
     foreach ($books as $book) {
     }
     $this->assertTrue(Propel::isInstancePoolingEnabled());
     Propel::disableInstancePooling();
     $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find($this->con);
     foreach ($books as $book) {
     }
     $this->assertFalse(Propel::isInstancePoolingEnabled());
     Propel::enableInstancePooling();
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:14,代码来源:PropelOnDemandIteratorTest.php


示例13: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$fixturesDirectory = realpath(dirname(dirname(__DIR__)) . '/fixtures');
     \Curry_Core::init(array('curry' => array('name' => 'Curry Unit Tests', 'adminEmail' => '[email protected]', 'autoBackup' => false, 'projectPath' => self::$fixturesDirectory, 'migrationVersion' => \Curry_Core::MIGRATION_VERSION, 'template' => array('root' => self::$fixturesDirectory . '/templates', 'options' => array('cache' => false)), 'propel' => array('conf' => self::$fixturesDirectory . '/propel/build/conf/curry-conf.php', 'projectClassPath' => self::$fixturesDirectory . '/propel/build/classes'))));
     // Empty database
     $con = \Propel::getConnection();
     $con->beginTransaction();
     try {
         foreach (\Curry_Propel::getModels(false) as $model) {
             \PropelQuery::from($model)->deleteAll();
         }
         $con->commit();
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
     $setup = new \Curry_Backend_Setup();
     $setup->saveConfiguration(array('template' => 'empty', 'admin' => array('username' => 'admin', 'password' => 'admin'), 'user' => array('username' => 'user', 'password' => 'user')));
 }
开发者ID:varvanin,项目名称:currycms,代码行数:20,代码来源:CmsTest.php


示例14: show

 public function show(Request $request)
 {
     $modelClass = $this->modelClass;
     $items = array();
     if ($this['id'] === ':id' && $request->query->has('item')) {
         $pks = array_map(function ($i) {
             return json_decode($i, true);
         }, $request->query->get('item', array()));
         if ($pks && $this->parent instanceof AbstractBackend) {
             $items = \PropelQuery::from($this->parent->getModelClass())->findPks($pks)->getArrayCopy();
         }
     } else {
         $items = array($this->getSelection());
     }
     $items = array_filter($items, function ($item) use($modelClass) {
         return $item instanceof $modelClass;
     });
     if (!count($items)) {
         throw new \Exception('No item to delete');
     }
     $names = array_map(function ($item) {
         return method_exists($item, '__toString') ? '`' . htmlspecialchars((string) $item) . '`' : 'this item';
     }, $items);
     if ($request->isMethod('POST') && $request->request->get('do_delete')) {
         foreach ($items as $i => $item) {
             $pk = $item->getPrimaryKey();
             $item->delete();
             // Trigger update event
             //$this->createModelUpdateEvent($this->modelClass, $pk, 'delete');
             if ($item instanceof \Curry_ISearchable) {
                 \Curry_Backend_Indexer::removeItem($item);
             }
         }
         $this->addMainContent('<p>' . $names[$i] . ' has been deleted.</p>');
     } else {
         $this->addMainContent('<form method="post">' . '<input type="hidden" name="do_delete" value="1" />' . '<p>Do you really want to delete ' . join(', ', $names) . '?</p>' . '<button type="submit" class="btn btn-danger">Delete</button>' . '</form>');
     }
     return parent::render();
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:39,代码来源:Delete.php


示例15: testToArray

 public function testToArray()
 {
     $books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find();
     $booksArray = $books->toArray();
     $this->assertEquals(4, count($booksArray));
     $bookObjects = PropelQuery::from('Book')->find();
     foreach ($booksArray as $key => $book) {
         $this->assertEquals($bookObjects[$key]->toArray(), $book);
     }
     $booksArray = $books->toArray();
     $keys = array(0, 1, 2, 3);
     $this->assertEquals($keys, array_keys($booksArray));
     $booksArray = $books->toArray(null, true);
     $keys = array('Book_0', 'Book_1', 'Book_2', 'Book_3');
     $this->assertEquals($keys, array_keys($booksArray));
     $booksArray = $books->toArray('Title');
     $keys = array('Harry Potter and the Order of the Phoenix', 'Quicksilver', 'Don Juan', 'The Tin Drum');
     $this->assertEquals($keys, array_keys($booksArray));
     $booksArray = $books->toArray('Title', true);
     $keys = array('Book_Harry Potter and the Order of the Phoenix', 'Book_Quicksilver', 'Book_Don Juan', 'Book_The Tin Drum');
     $this->assertEquals($keys, array_keys($booksArray));
 }
开发者ID:rubensayshi,项目名称:propelsandbox,代码行数:22,代码来源:PropelArrayCollectionTest.php


示例16: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method (this validator can only be used as a post validator).');
     }
     if (!is_array($this->getOption('column'))) {
         $this->setOption('column', array($this->getOption('column')));
     }
     if (!is_array($field = $this->getOption('field'))) {
         $this->setOption('field', $field ? array($field) : array());
     }
     $fields = $this->getOption('field');
     $criteria = PropelQuery::from($this->getOption('model'));
     foreach ($this->getOption('query_methods') as $method) {
         $criteria->{$method}();
     }
     foreach ($this->getOption('column') as $i => $column) {
         $name = isset($fields[$i]) ? $fields[$i] : $column;
         if (!array_key_exists($name, $values)) {
             // one of the column has been removed from the form
             return $values;
         }
         $colName = call_user_func(array(constant($this->getOption('model') . '::PEER'), 'translateFieldName'), $column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
         $criteria->add($colName, $values[$name]);
     }
     $object = $criteria->findOne($this->getOption('connection'));
     // if no object or if we're updating the object, it's ok
     if (null === $object || $this->isUpdate($object, $values)) {
         return $values;
     }
     $error = new sfValidatorError($this, 'invalid', array('column' => implode(', ', $this->getOption('column'))));
     if ($this->getOption('throw_global_error')) {
         throw $error;
     }
     $columns = $this->getOption('column');
     throw new sfValidatorErrorSchema($this, array($columns[0] => $error));
 }
开发者ID:sanemat,项目名称:bllik,代码行数:40,代码来源:sfValidatorPropelUnique.class.php


示例17: flushQueue

  /**
   * Sends messages using the given transport instance.
   *
   * @param Swift_Transport $transport         A transport instance
   * @param string[]        &$failedRecipients An array of failures by-reference
   *
   * @return int The number of sent emails
   */
  public function flushQueue(Swift_Transport $transport, &$failedRecipients = null)
  {
    $queryMethod = $this->method;
    $model = constant($this->model.'::PEER');
    $modelQuery = PropelQuery::from($this->model);
    $objects = $modelQuery->$queryMethod()->limit($this->getMessageLimit())->find();
    
    if (!$transport->isStarted())
    {
      $transport->start();
    }

    $method = 'get'.call_user_func(array($model, 'translateFieldName'), $this->column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
    $count = 0;
    $time = time();
    foreach ($objects as $object)
    {
      $message = unserialize($object->$method());
      try
      {
        $count += $transport->send($message, $failedRecipients);
        $object->mailSent();
      }
      catch (Exception $e)
      {
        $object->mailUnsent();
      }

      if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit())
      {
        break;
      }
    }

    return $count;
  }
开发者ID:nibsirahsieu,项目名称:sfNestedCommentPlugin,代码行数:44,代码来源:Swift_sfNestedCommentPool.class.php


示例18: useQuery

 /**
  * Initializes a secondary ModelCriteria object, to be later merged with the current object
  *
  * @see       ModelCriteria::endUse()
  * @param string $relationName        Relation name or alias
  * @param string $secondCriteriaClass Classname for the ModelCriteria to be used
  *
  * @return ModelCriteria The secondary criteria object
  *
  * @throws PropelException
  */
 public function useQuery($relationName, $secondaryCriteriaClass = null)
 {
     if (!isset($this->joins[$relationName])) {
         throw new PropelException('Unknown class or alias ' . $relationName);
     }
     $className = $this->joins[$relationName]->getTableMap()->getPhpName();
     if (null === $secondaryCriteriaClass) {
         $secondaryCriteria = PropelQuery::from($className);
     } else {
         $secondaryCriteria = new $secondaryCriteriaClass();
     }
     if ($className != $relationName) {
         $secondaryCriteria->setModelAlias($relationName, $relationName == $this->joins[$relationName]->getRelationMap()->getName() ? false : true);
     }
     $secondaryCriteria->setPrimaryCriteria($this, $this->joins[$relationName]);
     return $secondaryCriteria;
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:28,代码来源:ModelCriteria.php


示例19: updateItem

 /**
  * Add or update propel model item in search index.
  *
  * @param BaseObject $item
  * @param Zend_Search_Lucene_Interface $index
  * @param bool $removeOld
  * @return bool
  */
 public static function updateItem(BaseObject $item, Zend_Search_Lucene_Interface $index = null, $removeOld = true)
 {
     $model = get_class($item);
     try {
         if (!$index) {
             $index = \Curry\App::getInstance()->index;
         }
         if ($removeOld) {
             self::removeItem($item, $index);
         }
         $hasI18n = in_array('i18n', array_keys(PropelQuery::from($model)->getTableMap()->getBehaviors()));
         if ($hasI18n) {
             $translations = $item->{"get{$model}I18ns"}();
             foreach ($translations as $translation) {
                 $item->setLocale($translation->getLocale());
                 self::addSearchDocument($index, $item->getSearchDocument(), $item, $translation->getLocale());
             }
         } else {
             self::addSearchDocument($index, $item->getSearchDocument(), $item);
         }
         return true;
     } catch (Exception $e) {
         \Curry\App::getInstance()->logger->error($model . '(' . (string) $item . '): ' . $e->getMessage());
         return false;
     }
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:34,代码来源:Indexer.php


示例20: getJson

 /**
  * Get json response.
  *
  * @return mixed
  */
 public function getJson()
 {
     if (isPost() && isset($_POST['action'])) {
         return $this->runAction($_POST['action']);
     }
     if (!isset($_GET['key'])) {
         $root = \PropelQuery::from($this->model)->findRoot();
         return $root ? array($this->_objectToJson($root)) : array();
     } else {
         $parent = \PropelQuery::from($this->model)->findPk($_GET['key']);
         if (!$parent) {
             return array();
         }
         $p = $this->_objectToJson($parent);
         return $p['children'];
     }
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:22,代码来源:PropelTree.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP PropelQuickBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP PropelPDO类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap