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

PHP CategoryPeer类代码示例

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

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



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

示例1: getParent

 public function getParent()
 {
     if ($this->getParentId() != 0) {
         return CategoryPeer::retrieveByPk($this->getParentId());
     }
     return false;
 }
开发者ID:Chipusy,项目名称:lkbroker,代码行数:7,代码来源:Category.php


示例2: executeView

 public function executeView(sfWebRequest $request)
 {
     $category = CategoryPeer::retrieveByName($request->getParameter('category_name'));
     $this->forward404Unless($category);
     if ($category->getParentId() != 0) {
         $this->parentCategory = CategoryPeer::retrieveByPk($category->getParentId());
     } else {
         $this->subCategorys = CategoryPeer::getAllSub($category->getId());
     }
     $c = new Criteria();
     if (isset($this->subCategorys)) {
         $subCategoryIds = array();
         foreach ($this->subCategorys[$category->getId()] as $sub) {
             $subCategoryIds[] = $sub->getId();
         }
         $subCategoryIds[] = $category->getId();
         $c->add(ElementPeer::CATEGORY_ID, $subCategoryIds, Criteria::IN);
     } else {
         $c->add(ElementPeer::CATEGORY_ID, $category->getId());
     }
     $this->pager = new sfPropelPager('Element', 10);
     $this->pager->setPeerMethod('doSelectJoinAll');
     $this->pager->setCriteria($c);
     $this->pager->setPage($this->getRequestParameter('page'), 1);
     $this->pager->init();
     $this->elements = $this->pager->getResults();
     $this->category = $category;
 }
开发者ID:Chipusy,项目名称:lkbroker,代码行数:28,代码来源:actions.class.php


示例3: getForExpertCategoryUserId

 static function getForExpertCategoryUserId($user_id)
 {
     $c = new Criteria();
     $c->add(ExpertCategoryPeer::USER_ID, $user_id);
     $c->addJoin(ExpertCategoryPeer::CATEGORY_ID, CategoryPeer::ID);
     return CategoryPeer::doSelect($c);
 }
开发者ID:rayku,项目名称:rayku,代码行数:7,代码来源:CategoryPeer.php


示例4: executeAddArticleAndSave

 public function executeAddArticleAndSave(sfWebRequest $request)
 {
     $article = new Article();
     $article->setTitle(__METHOD__ . '()');
     $category = CategoryPeer::retrieveByPK($request->getParameter('category_id'));
     $category->addArticle($article);
     $category->save();
     return sfView::NONE;
 }
开发者ID:laiello,项目名称:tesiscdfeg12,代码行数:9,代码来源:actions.class.php


示例5: executeShowForum

 /**
  * The component to display a single forum (i.e. the threads in it)
  */
 public function executeShowForum()
 {
     $this->category = CategoryPeer::retrieveByPK($this->forumID);
     if ($this->category == NULL) {
         $this->category = ForumPeer::retrieveByPK($this->forumID);
     }
     $c = ThreadPeer::getCriteriaForCategory($this->forumID);
     $pager = new sfPropelPager('Thread', 10);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $raykuPager = new RaykuPagerRenderer($pager);
     $raykuPager->setBaseUrl('@view_page?forum_id=' . $this->category->getId());
     $this->raykuPager = $raykuPager;
 }
开发者ID:rayku,项目名称:rayku,代码行数:18,代码来源:components.class.php


示例6: executeCategory

 public function executeCategory($request)
 {
     $category = CategoryPeer::retrieveByPk($request->getParameter('category[id]'));
     $this->form = new CategoryForm($category);
     if ($request->getParameter('global')) {
         $this->form->getValidatorSchema()->getPostValidator()->setOption('throw_global_error', true);
     }
     if ($request->isMethod(sfRequest::POST)) {
         $this->form->bind($request->getParameter('category'));
         if ($this->form->isValid()) {
             $this->form->save();
             $this->redirect('unique/ok');
         }
     }
 }
开发者ID:laiello,项目名称:tesiscdfeg12,代码行数:15,代码来源:actions.class.php


示例7: doSelectJoinAllExceptProduct

 /**
  * Selects a collection of CategoryHasProduct objects pre-filled with all related objects except Product.
  *
  * @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 CategoryHasProduct objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptProduct(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);
     }
     CategoryHasProductPeer::addSelectColumns($criteria);
     $startcol2 = CategoryHasProductPeer::NUM_COLUMNS - CategoryHasProductPeer::NUM_LAZY_LOAD_COLUMNS;
     CategoryPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (CategoryPeer::NUM_COLUMNS - CategoryPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(CategoryHasProductPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseCategoryHasProductPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = CategoryHasProductPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = CategoryHasProductPeer::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 = CategoryHasProductPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             CategoryHasProductPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Category rows
         $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = CategoryPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = CategoryPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 CategoryPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (CategoryHasProduct) to the collection in $obj2 (Category)
             $obj2->addCategoryHasProduct($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
开发者ID:alexspark21,项目名称:symfony_bisM,代码行数:63,代码来源:BaseCategoryHasProductPeer.php


示例8: addSortCriteria

 protected function addSortCriteria($criteria)
 {
     if (array(null, null) == ($sort = $this->getSort())) {
         return;
     }
     $column = CategoryPeer::translateFieldName($sort[0], BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
     if ('asc' == $sort[1]) {
         $criteria->addAscendingOrderByColumn($column);
     } else {
         $criteria->addDescendingOrderByColumn($column);
     }
 }
开发者ID:Chipusy,项目名称:lkbroker,代码行数:12,代码来源:actions.class.php


示例9: doSelectJoinAll

 /**
  * Selects a collection of Product objects pre-filled with all related objects.
  *
  * @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 Product objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(ProductPeer::DATABASE_NAME);
     }
     ProductPeer::addSelectColumns($criteria);
     $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS;
     CategoryPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(ProductPeer::CATEGORY_ID, CategoryPeer::ENTITY_ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = ProductPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ProductPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Category rows
         $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = CategoryPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = CategoryPeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 CategoryPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (Product) to the collection in $obj2 (Category)
             $obj2->addProduct($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
开发者ID:Heisenberg87,项目名称:zendshop,代码行数:57,代码来源:BaseProductPeer.php


示例10: executeExpertReplyThread

    public function executeExpertReplyThread()
    {
        $connection = RaykuCommon::getDatabaseConnection();
        $c = new Criteria();
        $c->add(ForumPeer::TYPE, 0);
        $this->publicforums = ForumPeer::doSelect($c);
        $this->allcategories = CategoryPeer::doSelect($c = new Criteria());
        $this->forum = $this->getRequestParameter('forum_id');
        $this->thread = ThreadPeer::retrieveByPK($this->getRequestParameter('thread_id'));
        $c = new Criteria();
        $c->add(PostPeer::THREAD_ID, $this->thread->getId());
        $this->post = PostPeer::doSelectOne($c);
        $user = $this->getUser()->getRaykuUser();
        if ($this->getRequestParameter('post_edit_content') != '') {
            $threadId = $this->getRequestParameter('thread_id');
            $_thread = ThreadPeer::retrieveByPK($threadId);
            $_thread->setTitle($this->getRequestParameter('post_edit_title'));
            $_thread->save();
            $v = new Criteria();
            $v->add(PostPeer::THREAD_ID, $threadId);
            $v->addAscendingOrderByColumn(PostPeer::ID);
            $post = PostPeer::doSelectOne($v);
            $post->setContent($this->getRequestParameter('post_edit_content'));
            $post->save();
            return $this->redirect('@view_thread?thread_id=' . $threadId);
        }
        if ($this->getRequestParameter('post_body') != '') {
            if ($this->getRequestParameter('final_id') != '') {
                $_quick_reply = '';
                $_post_id = $this->getRequestParameter('final_id');
                $_Post = PostPeer::retrieveByPK($_post_id);
                $_User = UserPeer::retrieveByPK($_Post->getPosterId());
                $_quick_reply .= "<div style='margin-left:20px'><em><strong>Quote from " . $_User->getUsername() . "</strong></em><br><br>";
                $_explode_post = explode("*^-", $_Post->getContent());
                if (count($_explode_post) > 1) {
                    $_quick_reply .= $_explode_post[1];
                } else {
                    $_quick_reply .= $_Post->getContent();
                }
                $_quick_reply .= "</div>";
                $_post_body_msg = $this->getRequestParameter('post_body');
                $_quick_reply .= $_post_body_msg;
                $user->makeNewPost($this->getRequestParameter('thread_id'), $_quick_reply);
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            } else {
                $user->makeNewPost($this->getRequestParameter('thread_id'), $this->getRequestParameter('post_body'));
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            }
            if ($this->getUser()->getRaykuUser()->getType() == '5') {
                $c = new Criteria();
                $c->add(ThreadPeer::ID, $this->getRequestParameter('thread_id'));
                $thread = ThreadPeer::doSelectOne($c);
                $c = new Criteria();
                $c->add(UserPeer::ID, $thread->getPosterId());
                $user = UserPeer::doSelectOne($c);
                if ($thread->getNotifyPm() == '1') {
                    $subject = 'Expert Response for your Question';
                    $body = 'Hi there, <br><br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '" has just responsed to your question, "' . $thread->getTitle() . '" on the question boards. Take a look!<br><br>
							Rayku Administration';
                    //Grab the user object
                    $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId());
                    //Send the message
                    $currentuser->sendMessage($user->getId(), $subject, $body);
                }
                if ($thread->getNotifyEmail() == '1') {
                    $this->mail = new sfMail();
                    //Set the to, from, and subject headers
                    $this->mail->addAddress($user->getEmail());
                    $this->mail->setFrom('Expert <' . $this->getUser()->getRaykuUser()->getEmail() . '>');
                    $this->mail->setSubject('Expert Response to your Question');
                    $this->mail->setBody('Hi there,<br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '", has just responded to your question (below) on the question boards. Take a look!<br><br>
							' . $thread->getTitle() . '');
                    $this->mail->send();
                }
            }
            return $this->redirect('@view_thread?thread_id=' . $this->thread->getId());
        }
    }
开发者ID:rayku,项目名称:rayku,代码行数:86,代码来源:actions.class.php


示例11: execute

 public function execute($request)
 {
     $connection = RaykuCommon::getDatabaseConnection();
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $currentUser = $this->getUser()->getRaykuUser();
     $userId = $currentUser->getId();
     $this->userId = $currentUser->getId();
     $time = time();
     if (empty($_SESSION["course_id"])) {
         $_SESSION["course_id"] = '1';
     }
     $this->cat = $this->getRequestParameter('category');
     $this->course_id = $this->getRequestParameter('course');
     if (empty($this->course_id)) {
         if (!empty($_SESSION['course_id'])) {
             $this->course_id = $_SESSION['course_id'];
         } else {
             $this->course_id = 1;
         }
     } else {
         $_SESSION['course_id'] = $this->course_id;
     }
     if (empty($this->cat)) {
         if (!empty($_SESSION['subject'])) {
             $this->cat = $_SESSION['subject'];
         } else {
             $this->cat = 1;
         }
     } else {
         $_SESSION['subject'] = $this->cat;
     }
     $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
     $c = new Criteria();
     $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN);
     if ($this->cat == 5) {
         $experts = ExpertCategoryPeer::doSelect($c);
     } else {
         $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat);
         $experts = ExpertCategoryPeer::doSelect($c);
     }
     $queryPoints = mysql_query("select * from user where id = " . $userId, $connection) or die("Error In rate" . mysql_error());
     if (mysql_num_rows($queryPoints) > 0) {
         $rowPoints = mysql_fetch_assoc($queryPoints);
         $_points = $rowPoints['points'];
     }
     $newUser = array();
     $i = 0;
     $eachExpertOnlyOnce = array();
     foreach ($experts as $exp) {
         if ($userId != $exp->getUserId()) {
             if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) {
                 continue;
             }
             $eachExpertOnlyOnce[] = $exp->getUserId();
             /* Testing - Student match with Tutors */
             $_queryCourse = '';
             $tutorsq = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error());
             $tutors = mysql_fetch_array($tutorsq);
             $tutor = '';
             $tutor = explode("-", $tutors['course_id']);
             if (in_array($_SESSION["course_id"], $tutor)) {
                 $_queryCourse = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error());
                 //echo "select * from tutor_profile where category = 1 and user_id = ".$exp->getUserId()."";
             }
             if (@mysql_num_rows($_queryCourse) > 0) {
                 $query = mysql_query("select * from user_score where user_id = " . $exp->getUserId(), $connection) or die(mysql_error());
                 $score = mysql_fetch_assoc($query);
                 if ($score['score'] != 0) {
                     if ($_points == '' || $_points == '0.00') {
                         $emptyRCquery = mysql_query("select * from user_rate where userid = " . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ", $connection) or die("Error In rate" . mysql_error());
                         if (mysql_num_rows($emptyRCquery) > 0) {
                             $dv = new Criteria();
                             $dv->add(UserPeer::ID, $exp->getUserId());
                             $_thisUser = UserPeer::doSelectOne($dv);
                             $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                             $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                             $i++;
                         }
                     } else {
                         $dv = new Criteria();
                         $dv->add(UserPeer::ID, $exp->getUserId());
                         $_thisUser = UserPeer::doSelectOne($dv);
                         $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt());
                         $i++;
                     }
                 }
             }
         }
     }
     asort($newUser);
     arsort($newUser);
     asort($rankUsersFinal);
     arsort($rankUsersFinal);
     $this->rankCheckUsers = $rankUsersFinal;
     ////if no online expert available redirecting to the board page
     // // ant-edit remove for now
     $onlineusers = array();
     $offlineusers = array();
     $newOnlineUser = array();
//.........这里部分代码省略.........
开发者ID:rayku,项目名称:rayku,代码行数:101,代码来源:appendAction.class.php


示例12: retrieveByPKs

 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(CategoryPeer::ID, $pks, Criteria::IN);
         $objs = CategoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
开发者ID:kotow,项目名称:work,代码行数:15,代码来源:BaseCategoryPeer.php


示例13: Criteria

$c = new Criteria();
$c->add(AttachmentPeer::NAME, $name);
$attachments = AttachmentPeer::doSelect($c);
$b->test()->is(count($attachments), 1, 'the attachment has been saved in the database');
$b->test()->ok($attachments[0]->getArticleId(), 'the attachment is tied to an article');
$b->test()->is($attachments[0]->getFile(), 'uploaded.yml', 'the attachment filename has been saved in the database');
// sfValidatorPropelUnique
// create a category with a unique name
$b->get('/unique/category')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'category')->end()->with('response')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo')))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
// create another category with the same name
// we must have an error
$b->get('/unique/category')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'category')->end()->with('response')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo')))->with('form')->begin()->hasErrors(1)->hasGlobalError(false)->isError('name', 'invalid')->end()->with('response')->begin()->checkElement('td[colspan="2"] .error_list li', 0)->checkElement('.error_list li', 'An object with the same "name" already exist.')->checkElement('.error_list li', 1)->end();
// same thing but with a global error
$b->get('/unique/category')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'category')->end()->with('response')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo'), 'global' => 1))->with('form')->begin()->hasErrors(1)->hasGlobalError('invalid')->isError('name', false)->end()->with('response')->begin()->checkElement('td[colspan="2"] .error_list li', 'An object with the same "name" already exist.')->checkElement('td[colspan="2"] .error_list li', 1)->end();
// updating the same category again with the same name is allowed
$b->get('/unique/category?category[id]=' . CategoryPeer::getByName('foo')->getId())->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'category')->end()->with('response')->isStatusCode(200)->click('submit')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
// create an article with a unique title-category_id
$b->get('/unique/article')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'article')->end()->with('response')->isStatusCode(200)->click('submit', array('article' => array('title' => 'foo', 'category_id' => 1)))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
// create another article with the same title but a different category_id
$b->get('/unique/article')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'article')->end()->with('response')->isStatusCode(200)->click('submit', array('article' => array('title' => 'foo', 'category_id' => 2)))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
// create another article with the same title and category_id as the first one
// we must have an error
$b->get('/unique/article')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'article')->end()->with('response')->isStatusCode(200)->click('submit', array('article' => array('title' => 'foo', 'category_id' => 1)))->with('response')->checkElement('.error_list li', 'An object with the same "title, category_id" already exist.');
// update the category from the article form
$b->get('/unique/edit')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('input[value="foo title"]')->checkElement('#article_category_id option[selected="selected"]', 1)->checkElement('input[value="Category 1"]')->end()->click('submit', array('article' => array('title' => 'foo bar', 'category' => array('name' => 'Category foo'))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="foo bar"]')->checkElement('#article_category_id option[selected="selected"]', 1)->checkElement('input[value="Category foo"]')->end();
// sfValidatorPropelChoice
// submit a form with an impossible choice validator
$b->get('/choice/article')->with('request')->begin()->isParameter('module', 'choice')->isParameter('action', 'article')->end()->with('response')->begin()->isStatusCode(200)->end()->click('submit', array('article' => array('title' => 'foobar', 'category_id' => 1, 'author_article_list' => array(1)), 'impossible_validator' => 1))->with('form')->begin()->hasErrors(1)->isError('category_id', 'invalid')->end();
// sfValidatorPropelChoice (multiple == true)
// submit a form with an impossible choice validator
$b->get('/choice/article')->with('request')->begin()->isParameter('module', 'choice')->isParameter('action', 'article')->end()->with('response')->begin()->isStatusCode(200)->end()->click('submit', array('article' => array('title' => 'foobar', 'category_id' => 1, 'author_article_list' => array(1)), 'impossible_validator_many' => 1))->with('form')->begin()->hasErrors(1)->isError('author_article_list', 'invalid')->end();
开发者ID:cuongnv540,项目名称:jobeet,代码行数:31,代码来源:formTest.php


示例14: file_get_contents

AttachmentPeer::doDeleteAll();
$b->test()->ok(!file_exists($uploadedFile), 'uploaded file is deleted');
// file upload in embedded form
$b->getAndCheck('attachment', 'embedded')->with('response')->begin()->checkElement('input[name="article[attachment][article_id]"]', false)->checkElement('input[type="file"][name="article[attachment][file]"]')->end()->setField('article[title]', 'Test Article')->setField('article[attachment][name]', $name)->setField('article[attachment][file]', $fileToUpload)->click('submit')->with('form')->hasErrors(false)->isRedirected()->followRedirect()->with('response')->contains('ok');
$b->test()->ok(file_exists($uploadedFile), 'file is uploaded');
$b->test()->is(file_get_contents($uploadedFile), file_get_contents($fileToUpload), 'file is correctly uploaded');
$c = new Criteria();
$c->add(AttachmentPeer::NAME, $name);
$attachments = AttachmentPeer::doSelect($c);
$b->test()->is(count($attachments), 1, 'the attachment has been saved in the database');
$b->test()->ok($attachments[0]->getArticleId(), 'the attachment is tied to an article');
$b->test()->is($attachments[0]->getFile(), 'uploaded.yml', 'the attachment filename has been saved in the database');
// sfValidatorPropelUnique
// create a category with a unique name
$b->get('/unique/category')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'category')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo')))->isRedirected()->followRedirect()->responseContains('ok');
// create another category with the same name
// we must have an error
$b->get('/unique/category')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'category')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo')))->with('form')->begin()->hasErrors(1)->hasGlobalError(false)->isError('name', 'invalid')->end()->checkResponseElement('td[colspan="2"] .error_list li', 0)->checkResponseElement('.error_list li', 'An object with the same "name" already exist.')->checkResponseElement('.error_list li', 1);
// same thing but with a global error
$b->get('/unique/category')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'category')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo'), 'global' => 1))->with('form')->begin()->hasErrors(1)->hasGlobalError('invalid')->isError('name', false)->end()->checkResponseElement('td[colspan="2"] .error_list li', 'An object with the same "name" already exist.')->checkResponseElement('td[colspan="2"] .error_list li', 1);
// updating the same category again with the same name is allowed
$b->get('/unique/category?category[id]=' . CategoryPeer::getByName('foo')->getId())->isRequestParameter('module', 'unique')->isRequestParameter('action', 'category')->isStatusCode(200)->click('submit')->isRedirected()->followRedirect()->responseContains('ok');
// create an article with a unique title-category_id
$b->get('/unique/article')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'article')->isStatusCode(200)->click('submit', array('article' => array('title' => 'foo', 'category_id' => 1)))->isRedirected()->followRedirect()->responseContains('ok');
// create another article with the same title but a different category_id
$b->get('/unique/article')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'article')->isStatusCode(200)->click('submit', array('article' => array('title' => 'foo', 'category_id' => 2)))->isRedirected()->followRedirect()->responseContains('ok');
// create another article with the same title and category_id as the first one
// we must have an error
$b->get('/unique/article')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'article')->isStatusCode(200)->click('submit', array('article' => array('title' => 'foo', 'category_id' => 1)))->checkResponseElement('.error_list li', 'An object with the same "title, category_id" already exist.');
// update the category from the article form
$b->get('/unique/edit')->isRequestParameter('module', 'unique')->isRequestParameter('action', 'edit')->isStatusCode(200)->checkResponseElement('input[value="foo title"]')->checkResponseElement('#article_category_id option[selected="selected"]', 1)->checkResponseElement('input[value="Category 1"]')->click('submit', array('article' => array('title' => 'foo bar', 'category' => array('name' => 'Category foo'))))->isRedirected()->followRedirect()->checkResponseElement('input[value="foo bar"]')->checkResponseElement('#article_category_id option[selected="selected"]', 1)->checkResponseElement('input[value="Category foo"]');
开发者ID:habtom,项目名称:uas,代码行数:31,代码来源:formTest.php


示例15: getCategory

 public function getCategory(PropelPDO $con = null)
 {
     if ($this->aCategory === null && $this->category_id !== null) {
         $c = new Criteria(CategoryPeer::DATABASE_NAME);
         $c->add(CategoryPeer::ID, $this->category_id);
         $this->aCategory = CategoryPeer::doSelectOne($c, $con);
     }
     return $this->aCategory;
 }
开发者ID:yasirgit,项目名称:afids,代码行数:9,代码来源:BaseArticle.php


示例16: sfTestFunctional

<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
$fixtures = 'fixtures/fixtures.yml';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
    return;
}
$b = new sfTestFunctional(new sfBrowser(), null, array('propel' => 'sfTesterPropel'));
ArticlePeer::doDeleteAll();
$c = CategoryPeer::doSelectOne(new Criteria());
$hash = spl_object_hash($c);
$b->get('/pooling/addArticleButDontSave/category_id/' . $c->getId())->with('propel')->check('Article', null, 0)->get('/pooling/addArticleAndSave/category_id/' . $c->getId())->with('propel')->check('Article', null, 1);
开发者ID:kcornejo,项目名称:estadistica,代码行数:19,代码来源:poolingTest.php


示例17: executeProductCategoriesList

 public function executeProductCategoriesList()
 {
     $this->setLayout(false);
     $c = new Criteria();
     $this->categories = CategoryPeer::doSelect($c);
     $prodNum = array();
     foreach ($this->categories as $cat) {
         $id = $cat->getId();
         $products = Document::getChildrenOf($cat, "Product", false);
         // count ACTIVE childrens
         $cnt = 0;
         foreach ($products as $product) {
             if ($product->getPublicationStatus() == UtilsHelper::STATUS_ACTIVE) {
                 $cnt++;
             }
         }
         $prodNum[$id] = $cnt;
     }
     $this->prodNum = $prodNum;
     $this->currentId = $this->getRequestParameter("Category_id");
 }
开发者ID:kotow,项目名称:work,代码行数:21,代码来源:actions.class.php


示例18: doSelectJoinAllExceptBook

 public static function doSelectJoinAllExceptBook(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ArticlePeer::addSelectColumns($c);
     $startcol2 = ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS;
     CategoryPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (CategoryPeer::NUM_COLUMNS - CategoryPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(ArticlePeer::CATEGORY_ID), array(CategoryPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ArticlePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ArticlePeer::getInstanceFromPool($key1))) {
         } else {
             $omClass = ArticlePeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ArticlePeer::addInstanceToPool($obj1, $key1);
         }
         $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = CategoryPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = CategoryPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 CategoryPeer::addInstanceToPool($obj2, $key2);
             }
             $obj2->addArticle($obj1);
         }
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
开发者ID:yasirgit,项目名称:afids,代码行数:40,代码来源:BaseArticlePeer.php


示例19: doSelectJoinAllExceptBook

 public static function doSelectJoinAllExceptBook(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ArticlePeer::addSelectColumns($c);
     $startcol2 = ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     CategoryPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + CategoryPeer::NUM_COLUMNS;
     $c->addJoin(ArticlePeer::CATEGORY_ID, CategoryPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = ArticlePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = CategoryPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getCategory();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addArticle($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initArticles();
             $obj2->addArticle($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:40,代码

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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