当前位置: 首页>>代码示例>>PHP>>正文


PHP CategoryModel::all方法代码示例

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


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

示例1: searchCategories

 static function searchCategories($query, $limit = 10)
 {
     //        $query = mysql_real_escape_string($query);
     $categoryObjects = CategoryModel::all(array('conditions' => 'categories_lang.name LIKE \'%' . $query . '%\'', "limit" => $limit, 'order' => '`order` ASC, `id` ASC', 'joins' => array('categories_lang'), 'group' => 'id'));
     $categories = array();
     foreach ($categoryObjects as $c) {
         $cat = Activerecord::returnArrayWithLang($c);
         $categories[] = $cat;
     }
     return $categories;
 }
开发者ID:git-ecorise,项目名称:ctshop,代码行数:11,代码来源:CategoryModel.php

示例2: getCategoryId

 /**
  * will query the db and get all the categories, if the categoryName is not
  * in the categories table, it will insert it,
  * otherwise it will return the category id
  */
 public static function getCategoryId($categoryName)
 {
     $categories = CategoryModel::all();
     // find the category id
     foreach ($categories as $cat) {
         if ($categoryName == $cat['category_name']) {
             return $cat['id'];
         }
     }
     // category wasn't found, so we need to insert one
     $query = 'INSERT INTO categories (category_name) VALUES (:category_name)';
     $stmt = static::$dbc->prepare($query);
     $stmt->bindValue(":category_name", $categoryName, PDO::PARAM_STR);
     $stmt->execute();
     return self::getCategoryId($categoryName);
 }
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:21,代码来源:CategoryModel.php

示例3: pageController

function pageController()
{
    $errors['count'] = 0;
    $arrayCategoriesArray = CategoryModel::all();
    foreach ($arrayCategoriesArray as $categoriesArray) {
        $categorySelectionList[] = $categoriesArray['category_name'];
    }
    $imageSuccessMessage = "";
    //if an image was submitted - validate it even before validating the rest of the form
    if (isset($_FILES['fileToUpload']) && $_FILES['fileToUpload']['name'] != '') {
        try {
            $postImage = Input::getImage('fileToUpload');
            //image was successfully uploaded
            $imageSuccessMessage = "Image: " . basename($_FILES['fileToUpload']['name']) . " has been uploaded!";
            //store image in the session
            $_SESSION['image'] = $postImage;
        } catch (Exception $e) {
            $errors['image'] = 'Image: ' . $e->getMessage();
            $errors['count']++;
        }
    }
    //clicked on the upload image button without selecting a photo
    if (isset($_FILES['fileToUpload']) && $_FILES['fileToUpload']['name'] == '') {
        $errors['image'] = "Image:  Select an image to upload!";
        $errors['count']++;
    }
    //if the session['image'] is empty; then, no image was submitted
    if (!isset($_SESSION['image'])) {
        //no image was submitted - use placeholder image
        $postImage = "http://placehold.it/350x300";
    } else {
        //an image has been submitted; use the image stored in the $_SESSION
        $postImage = $_SESSION['image'];
    }
    //if there weren't any errors with the image; then, process then rest of the form
    if ($errors['count'] == 0) {
        $errors = processForm($postImage);
    }
    return array('categorySelectionList' => $categorySelectionList, 'errorMessages' => $errors, 'imageSuccessMessage' => $imageSuccessMessage);
}
开发者ID:LZJCodeup,项目名称:AdLister,代码行数:40,代码来源:ads.create.php

示例4: fixCategoryOrderRecursive

 function fixCategoryOrderRecursive($parent_id = null)
 {
     $parent_condition = $parent_id != null ? '`parent_id` = ' . $parent_id : '`parent_id` IS NULL';
     $categories = CategoryModel::all(array('conditions' => $parent_condition, 'order' => '`order` ASC'));
     $order = 0;
     if ($categories != null) {
         foreach ($categories as $c) {
             $c->order = $order;
             $c->save();
             $order++;
             $this->fixCategoryOrderRecursive($c->id);
         }
     }
 }
开发者ID:git-ecorise,项目名称:ctshop,代码行数:14,代码来源:BCategories.php


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