Пример #1
0
 public function edit(Category $category)
 {
     $query = "Select id, name\n        FROM categories WHERE id = ?";
     $this->db->query($query, [$category->getId()]);
     $result = $this->db->row();
     if (!$result) {
         echo 'No such category';
         die;
     }
     $query = "Select id, name\n        FROM categories WHERE name = ?";
     $this->db->query($query, [$category->getName()]);
     $result = $this->db->row();
     if ($result) {
         echo 'The category with this name exists!';
         die;
     }
     $query = "Update categories SET name = ?\n        WHERE id = ?";
     $this->db->query($query, [$category->getName(), $category->getId()]);
     $result = $this->db->row();
     return $result;
 }
Пример #2
0
 /**
  * Declares an association between this object and a ChildCategory object.
  *
  * @param  ChildCategory $v
  * @return $this|\Models\Note The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCategory(ChildCategory $v = null)
 {
     if ($v === null) {
         $this->setCategoryId(NULL);
     } else {
         $this->setCategoryId($v->getId());
     }
     $this->aCategory = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildCategory object, it will not be re-added.
     if ($v !== null) {
         $v->addNote($this);
     }
     return $this;
 }
Пример #3
0
 /**
  * Exclude object from result
  *
  * @param   ChildCategory $category Object to remove from the list of results
  *
  * @return $this|ChildCategoryQuery The current query, for fluid interface
  */
 public function prune($category = null)
 {
     if ($category) {
         $this->addUsingAlias(CategoryTableMap::COL_ID, $category->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Пример #4
0
 /**
  * Filter the query by a related \Models\Category object
  *
  * @param \Models\Category $category The related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildSharedQuery The current query, for fluid interface
  */
 public function filterByCategory($category, $comparison = null)
 {
     if ($category instanceof \Models\Category) {
         return $this->addUsingAlias(SharedTableMap::COL_WHAT_TYPE, 'category', $comparison)->addUsingAlias(SharedTableMap::COL_WHAT_ID, $category->getId(), $comparison);
     } else {
         throw new PropelException('filterByCategory() only accepts arguments of type \\Models\\Category');
     }
 }
Пример #5
0
 /**
  * Filter the query by a related \Models\Category object
  *
  * @param \Models\Category|ObjectCollection $category The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildArticleQuery The current query, for fluid interface
  */
 public function filterByCategory($category, $comparison = null)
 {
     if ($category instanceof \Models\Category) {
         return $this->addUsingAlias(ArticleTableMap::COL_ID_CATEGORY, $category->getId(), $comparison);
     } elseif ($category instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ArticleTableMap::COL_ID_CATEGORY, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCategory() only accepts arguments of type \\Models\\Category or Collection');
     }
 }