コード例 #1
0
ファイル: CategoryQuery.php プロジェクト: OneTimeCZ/Tasker
 /**
  * Returns a new ChildCategoryQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildCategoryQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildCategoryQuery) {
         return $criteria;
     }
     $query = new ChildCategoryQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
コード例 #2
0
ファイル: Note.php プロジェクト: OneTimeCZ/Tasker
 /**
  * Get the associated ChildCategory object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildCategory The associated ChildCategory object.
  * @throws PropelException
  */
 public function getCategory(ConnectionInterface $con = null)
 {
     if ($this->aCategory === null && $this->category_id !== null) {
         $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aCategory->addNotes($this);
            */
     }
     return $this->aCategory;
 }
コード例 #3
0
ファイル: CategoryTableMap.php プロジェクト: OneTimeCZ/Tasker
 /**
  * Performs an INSERT on the database, given a Category or Criteria object.
  *
  * @param mixed               $criteria Criteria or Category object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Category object
     }
     if ($criteria->containsKey(CategoryTableMap::COL_ID) && $criteria->keyContainsValue(CategoryTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = CategoryQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
コード例 #4
0
ファイル: Category.php プロジェクト: OneTimeCZ/Tasker
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildCategoryQuery::create();
     $criteria->add(CategoryTableMap::COL_ID, $this->id);
     return $criteria;
 }
コード例 #5
0
ファイル: AdminController.php プロジェクト: OneTimeCZ/DofE
 public function articleEdit($name)
 {
     $id = explode('-', $name);
     $id = $id[0];
     $article = ArticleQuery::create()->findPk($id);
     if ($article == NULL) {
         $this->addPopup('danger', 'Článek se specifikovaným identifikačním číslem se v databázi nenachází.');
         redirectTo('/administrace/clanky');
     }
     if (!$this->isAdmin()) {
         if ($article->getIdUser() != $_SESSION["user"]->getId()) {
             $this->addPopup('danger', 'Pro úpravu cizích článků nemáte dostatečná práva.');
             redirectTo("/administrace/clanky");
         }
     }
     $categories = CategoryQuery::create()->find();
     $this->view('Admin/editArticle', 'admin_template', ['active' => 'list', 'title' => 'Upravit článek', 'js' => array('plugins/tinymce/tinymce.min', 'scripts/tinymceinit'), 'categories' => $categories, 'article' => $article]);
 }
コード例 #6
0
ファイル: NoteController.php プロジェクト: OneTimeCZ/Tasker
 protected function create()
 {
     $params = $this->getAllowedKeysForCreate();
     $note = new Note();
     $note->fromArray($params);
     $category = $_POST['category'];
     $category = CategoryQuery::create()->filterByUser($this->params['user'])->filterByName($category)->findOne();
     if ($category != null) {
         $note->setCategory($category);
     }
     $note->setUser($this->params['user']);
     $note->save();
     $this->addFlash("success", "Note added");
     redirectTo($note->getShowPath());
 }
コード例 #7
0
ファイル: User.php プロジェクト: OneTimeCZ/Tasker
 /**
  * Returns the number of related Category objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      ConnectionInterface $con
  * @return int             Count of related Category objects.
  * @throws PropelException
  */
 public function countCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collCategoriesPartial && !$this->isNew();
     if (null === $this->collCategories || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collCategories) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getCategories());
         }
         $query = ChildCategoryQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByUser($this)->count($con);
     }
     return count($this->collCategories);
 }