本文整理汇总了PHP中ArticlePeer类的典型用法代码示例。如果您正苦于以下问题:PHP ArticlePeer类的具体用法?PHP ArticlePeer怎么用?PHP ArticlePeer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArticlePeer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeEdit
public function executeEdit($request)
{
$this->form = new ArticleForm(ArticlePeer::doSelectOne(new Criteria()));
if ($request->isMethod(sfRequest::POST)) {
$this->form->bind($request->getParameter('article'));
if ($this->form->isValid()) {
$this->form->save();
$this->redirect('unique/edit');
}
}
}
示例2: executeShowArchive
public function executeShowArchive(sfWebRequest $request)
{
$c = new Criteria();
$year = $request->getParameter('year');
$month = $request->getParameter('month');
$nextMonth = mktime(0, 0, 0, $month + 1, 0, $year);
$thisMonth = mktime(0, 0, 0, $month, 0, $year);
$c->add(ArticlePeer::CREATED_AT, $nextMonth, Criteria::LESS_THAN);
$c->addAnd(ArticlePeer::CREATED_AT, $thisMonth, Criteria::GREATER_THAN);
// $c->addAnd(ArticlePeer::CREATED_AT,$thisMonth,'GREATERTHAN');
$this->posts = ArticlePeer::doSelect($c);
}
示例3: getArticle
public function getArticle(PropelPDO $con = null)
{
if ($this->aArticle === null && $this->article_id !== null) {
$c = new Criteria(ArticlePeer::DATABASE_NAME);
$c->add(ArticlePeer::ID, $this->article_id);
$this->aArticle = ArticlePeer::doSelectOne($c, $con);
}
return $this->aArticle;
}
示例4: getArticle
public function getArticle($con = null)
{
include_once 'lib/model/om/BaseArticlePeer.php';
if ($this->aArticle === null && $this->article_id !== null) {
$this->aArticle = ArticlePeer::retrieveByPK($this->article_id, $con);
}
return $this->aArticle;
}
示例5: fromArray
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* The default key type is the column's phpname (e.g. 'AuthorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = ArticlePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) {
$this->setId($arr[$keys[0]]);
}
if (array_key_exists($keys[1], $arr)) {
$this->setTitle($arr[$keys[1]]);
}
if (array_key_exists($keys[2], $arr)) {
$this->setContent($arr[$keys[2]]);
}
}
示例6: getArticle
public function getArticle($con = null)
{
if ($this->aArticle === null && $this->article_id !== null) {
$this->aArticle = ArticlePeer::retrieveByPK($this->article_id, $con);
}
return $this->aArticle;
}
示例7: fromArray
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* The default key type is the column's phpname (e.g. 'AuthorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = ArticlePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) {
$this->setId($arr[$keys[0]]);
}
if (array_key_exists($keys[1], $arr)) {
$this->setTitle($arr[$keys[1]]);
}
if (array_key_exists($keys[2], $arr)) {
$this->setBody($arr[$keys[2]]);
}
if (array_key_exists($keys[3], $arr)) {
$this->setOnline($arr[$keys[3]]);
}
if (array_key_exists($keys[4], $arr)) {
$this->setExcerpt($arr[$keys[4]]);
}
if (array_key_exists($keys[5], $arr)) {
$this->setCategoryId($arr[$keys[5]]);
}
if (array_key_exists($keys[6], $arr)) {
$this->setCreatedAt($arr[$keys[6]]);
}
if (array_key_exists($keys[7], $arr)) {
$this->setEndDate($arr[$keys[7]]);
}
if (array_key_exists($keys[8], $arr)) {
$this->setBookId($arr[$keys[8]]);
}
}
示例8: doSelectJoinAllExceptAuthor
/**
* Selects a collection of AuthorArticle objects pre-filled with all related objects except Author.
*
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return array Array of AuthorArticle objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAllExceptAuthor(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
// Set the correct dbName if it has not been overridden
// $criteria->getDbName() will return the same object if not set to another value
// so == check is okay and faster
if ($criteria->getDbName() == Propel::getDefaultDB()) {
$criteria->setDbName(self::DATABASE_NAME);
}
AuthorArticlePeer::addSelectColumns($criteria);
$startcol2 = AuthorArticlePeer::NUM_COLUMNS - AuthorArticlePeer::NUM_LAZY_LOAD_COLUMNS;
ArticlePeer::addSelectColumns($criteria);
$startcol3 = $startcol2 + (ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS);
$criteria->addJoin(AuthorArticlePeer::ARTICLE_ID, ArticlePeer::ID, $join_behavior);
// symfony_behaviors behavior
foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
call_user_func($sf_hook, 'BaseAuthorArticlePeer', $criteria, $con);
}
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$key1 = AuthorArticlePeer::getPrimaryKeyHashFromRow($row, 0);
if (null !== ($obj1 = AuthorArticlePeer::getInstanceFromPool($key1))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://propel.phpdb.org/trac/ticket/509
// $obj1->hydrate($row, 0, true); // rehydrate
} else {
$cls = AuthorArticlePeer::getOMClass(false);
$obj1 = new $cls();
$obj1->hydrate($row);
AuthorArticlePeer::addInstanceToPool($obj1, $key1);
}
// if obj1 already loaded
// Add objects for joined Article rows
$key2 = ArticlePeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
$obj2 = ArticlePeer::getInstanceFromPool($key2);
if (!$obj2) {
$cls = ArticlePeer::getOMClass(false);
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
ArticlePeer::addInstanceToPool($obj2, $key2);
}
// if $obj2 already loaded
// Add the $obj1 (AuthorArticle) to the collection in $obj2 (Article)
$obj2->addAuthorArticle($obj1);
}
// if joined row is not null
$results[] = $obj1;
}
$stmt->closeCursor();
return $results;
}
示例9: addSortCriteria
protected function addSortCriteria($c)
{
if ($sort_column = $this->getUser()->getAttribute('sort', null, 'sf_admin/article/sort')) {
$sort_column = sfInflector::camelize(strtolower($sort_column));
$sort_column = ArticlePeer::translateFieldName($sort_column, BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
if ($this->getUser()->getAttribute('type', null, 'sf_admin/article/sort') == 'asc') {
$c->addAscendingOrderByColumn($sort_column);
} else {
$c->addDescendingOrderByColumn($sort_column);
}
}
}
示例10: executeGetFixtureModel
/**
* @WSMethod(name='getFixtureModel')
*
* @return Article[] All articles loaded from the database.
*/
public function executeGetFixtureModel(sfWebRequest $request)
{
$this->result = ArticlePeer::doSelect(new Criteria());
return sfView::SUCCESS;
}
示例11: addSortCriteria
protected function addSortCriteria($criteria)
{
if (array(null, null) == ($sort = $this->getSort())) {
return;
}
$column = ArticlePeer::translateFieldName($sort[0], BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
if ('asc' == $sort[1]) {
$criteria->addAscendingOrderByColumn($column);
} else {
$criteria->addDescendingOrderByColumn($column);
}
}
示例12: executeArchiveList
public function executeArchiveList()
{
$c = new Criteria();
$c->addDescendingOrderByColumn('created_at');
$this->posts = ArticlePeer::doSelect($c);
}
示例13: executeShoppingCart2
public function executeShoppingCart2(sfWebRequest $request)
{
$this->categories = CategoryPeer::getActiveCategories();
$this->paths = array();
$promoter = $promoter = PromoterPeer::getPromoterByUserId($this->getUser()->getId());
$this->state = $promoter->getIdState();
$this->articles = ArticlePeer::doSelect(new Criteria());
if ($request->isMethod('post')) {
$cart = $this->createCartIfNotExists();
foreach ($this->articles as $key => $article) {
$value = $request->getParameter($article->getId());
if ($value > 0) {
$this->createCartArticle($cart, $article, $value);
}
}
}
$cart = CartPeer::getCart($promoter->getClientId());
if (!isset($cart)) {
$cart = new Cart();
}
$this->cart_articles = $cart->getCartArticles();
//sacar articulos mayor a 1 mes en el carrito
foreach ($this->cart_articles as $cart_article) {
$fecha = $this->dateadd($cart_article->getUpdatedAt(), 0, 1, 0, 0, 0, 0);
$date1 = new DateTime("now");
$date2 = new DateTime($fecha);
if ($date1 > $date2) {
$cart_article->delete();
$cart_article->save();
}
}
$this->total = 0;
foreach ($this->cart_articles as $cart_article) {
$this->total += $cart_article->getPrice() * $cart_article->getQuantity();
}
}
示例14: getArticle
static function getArticle($id)
{
$c = new Criteria();
$c->add(ArticlePeer::ID, $id);
return ArticlePeer::doSelectOne($c);
}
示例15: getArticlesJoinBook
public function getArticlesJoinBook($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseArticlePeer.php';
if ($criteria === null) {
$criteria = new Criteria();
} elseif ($criteria instanceof Criteria) {
$criteria = clone $criteria;
}
if ($this->collArticles === null) {
if ($this->isNew()) {
$this->collArticles = array();
} else {
$criteria->add(ArticlePeer::CATEGORY_ID, $this->getId());
$this->collArticles = ArticlePeer::doSelectJoinBook($criteria, $con);
}
} else {
$criteria->add(ArticlePeer::CATEGORY_ID, $this->getId());
if (!isset($this->lastArticleCriteria) || !$this->lastArticleCriteria->equals($criteria)) {
$this->collArticles = ArticlePeer::doSelectJoinBook($criteria, $con);
}
}
$this->lastArticleCriteria = $criteria;
return $this->collArticles;
}