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


PHP Category::find_by_id方法代码示例

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


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

示例1: __construct

 function __construct()
 {
     parent::__construct(__FILE__);
     // Remember this
     //creamos una categoria de test
     $this->load->model('category');
     $parent_id = NULL;
     $cat_attributes = array('name' => 'TEST_name', 'category_id' => $parent_id);
     Category::create($cat_attributes);
     $this->m_category = Category::find_by_id(Category::last()->id);
     $this->load->model('product');
     //buscamos cuantos productos hay de dicha categoria
     $this->m_category_products_count = Product::count_by_category_id($this->m_category->id);
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:14,代码来源:products_test.php

示例2: edit

 function edit($id = FALSE, $parent_id = FALSE)
 {
     //load block submit helper and append in the head
     $this->template->append_metadata(block_submit_button());
     //Rules for validation
     $this->_set_rules('edit');
     //get the parent id and sanitize
     $parent_id = $this->uri->segment(5) ? $this->uri->segment(5) : $this->input->post('parent_id', TRUE);
     $parent_id = $parent_id != 0 ? filter_var($parent_id, FILTER_VALIDATE_INT) : NULL;
     //get the $id and sanitize
     $id = $this->uri->segment(4) ? $this->uri->segment(4) : $this->input->post('id', TRUE);
     $id = $id != 0 ? filter_var($id, FILTER_VALIDATE_INT) : NULL;
     //redirect if it´s no correct
     if (!$id) {
         $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_object_not_exit')));
         redirect('admin/categories/');
     }
     //create control variables
     $this->template->title(lang("web_category_edit"));
     $this->template->set('category', Category::find_by_id($id));
     $this->template->set('updType', 'edit');
     $this->template->set('parent_id', $parent_id);
     if ($this->form_validation->run() == FALSE) {
         //load the view and the layout
         $this->template->build('categories/create');
     } else {
         // build array for the model
         $form_data = array('name' => $this->input->post('name', TRUE), 'id' => $this->input->post('id', TRUE));
         //find the item to update
         $category = Category::find($this->input->post('id', TRUE));
         $category->update_attributes($form_data);
         // run insert model to write data to db
         if ($category->is_valid()) {
             $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_edit_success')));
             redirect('admin/categories/' . $parent_id);
         }
         if ($category->is_invalid()) {
             $this->session->set_flashdata('message', array('type' => 'error', 'text' => $category->errors->full_messages()));
             redirect('admin/categories/' . $parent_id);
         }
     }
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:42,代码来源:categories.php

示例3: set_up_display

 protected function set_up_display()
 {
     if (isset($this->category_id)) {
         $category = Category::find_by_id((int) $this->category_id);
         $this->category = $category->category;
         //    $this->unit_price = $category->unit_price;
         $this->price = $this->unit_price * $this->quantity;
         $this->price_company = $this->company_unit_price * $this->quantity;
         if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
             $formatter = new NumberFormatter('en_CH', NumberFormatter::CURRENCY);
             $this->price = $formatter->formatCurrency($this->price, 'CHF');
             $this->price_company = $formatter->formatCurrency($this->price_company, 'CHF');
             //    $this->unit_price=$formatter->formatCurrency($this->unit_price, 'CHF');
             //    $this->company_unit_price=$formatter->formatCurrency($this->company_unit_price, 'CHF');
         }
     }
     if (isset($this->project_id)) {
         $project = Project::find_by_id((int) $this->project_id);
         $this->project_code = $project->project_code;
     }
 }
开发者ID:kamy333,项目名称:rajah,代码行数:21,代码来源:_template.php

示例4: return_url

<?php

/** cat */
$category_url = return_url();
$current_category = !empty($category_url[1]) ? $category_url[1] : 0;
$job_by_cats = JobCategory::top_ten_cat($current_category);
if ($job_by_cats) {
    $categorys = array();
    $i = 0;
    foreach ($job_by_cats as $job_by_cat) {
        $job_id = $job_by_cat->job_id;
        $cat_id = $job_by_cat->category_id;
        $total_jobs = JobCategory::get_total_job_by_cat($cat_id);
        if (Job::find_active_job_by_id($job_id)) {
            $cat_name = Category::find_by_id($cat_id);
            /**check length of text */
            $cat_names = strlen($cat_name->cat_name) > 25 ? substr($cat_name->cat_name, 0, 25) . " ... " : $cat_name->cat_name;
            $categorys[$i]['var_name'] = $cat_name->var_name;
            $categorys[$i]['category_name'] = $cat_names;
            $categorys[$i]['f_category_name'] = $cat_name->cat_name;
            $categorys[$i]['total_num'] = $total_jobs;
            $i++;
        }
    }
    $smarty->assign('job_by_cats', $categorys);
    $smarty->assign('job_by_categorys', $smarty->fetch('job_by_top_categorys.tpl'));
}
开发者ID:nim94sha,项目名称:Online-Job-Portal,代码行数:27,代码来源:jobs_by_top_category.php

示例5: display_content_box_header

function display_content_box_header($portal_id, $topic_id, $sub_topic_1_id, $sub_topic_2_id, $sub_topic_3_id, $sub_topic_4_id, $category_id)
{
    if ($category_id != 156) {
        $category = Category::find_by_id($category_id);
        $category_title = $category->category_title;
        $output = "<h2>{$category_title}</h2>";
    } elseif ($sub_topic_4_id != 156) {
        $sub_topic_4 = SubTopic4::find_by_id($sub_topic_4_id);
        $sub_topic_4_title = $sub_topic_4->sub_topic_4;
        $output = "<h2>{$sub_topic_4_title}</h2>";
    } elseif ($sub_topic_3_id != 156) {
        $sub_topic_3 = SubTopic3::find_by_id($sub_topic_3_id);
        $sub_topic_3_title = $sub_topic_3->sub_topic_3;
        $output = "<h2>{$sub_topic_3_title}</h2>";
    } elseif ($sub_topic_2_id != 156) {
        $sub_topic_2 = SubTopic2::find_by_id($sub_topic_2_id);
        $sub_topic_2_title = $sub_topic_2->sub_topic_2;
        $output = "<h2>{$sub_topic_2_title}</h2>";
    } elseif ($sub_topic_1_id != 156) {
        $sub_topic_1 = SubTopic1::find_by_id($sub_topic_1_id);
        $sub_topic_1_title = $sub_topic_1->sub_topic_1;
        $output = "<h2>{$sub_topic_1_title}</h2>";
    } elseif ($topic_id != 156) {
        $topic = Topic::find_by_id($topic_id);
        $topic_title = $topic->topic;
        $output = "<h2>This week in {$topic_title}</h2>";
    } elseif ($portal_id != 156) {
        $portal = Portal::find_by_id($portal_id);
        $portal_title = $portal->portal;
        $output = "<h2>This week in {$portal_title}</h2>";
    } else {
        $output = "<h2>This week in RazaWeb</h2>";
    }
    return $output;
}
开发者ID:kamalrazalatif,项目名称:razaweb,代码行数:35,代码来源:display_functions.php

示例6: foreach

      <section class="mainContent">
      <div class="productRow" id="productRow">
      <?php 
foreach ($products as $product) {
    ?>
        <article class="productInfo"><!-- Each individual product description -->
          <div><img src="../../<?php 
    echo $product->image_path();
    ?>
"/></div>
          <p class="price"><?php 
    echo $product->name;
    ?>
</p>
          <p class="productContent"><?php 
    $cat = Category::find_by_id($product->cat_id);
    echo $cat->get_name();
    ?>
</p>
          <p class="productContent"><?php 
    $user = User::find_by_id($product->userid);
    echo $user->full_name();
    ?>
</p>
		    </article>
	  <?php 
}
?>
      </div>
      <div id="pagination" style="clear: both;">
<?php 
开发者ID:hc-hacker,项目名称:My-OLX,代码行数:31,代码来源:index.php

示例7: format_lang

$categories = Category::find_by_id($cv_details->recent_industry_work);
$riw = $categories ? $categories->cat_name : format_lang('none');
$smarty->assign('riw', $riw);
$careers = CareerDegree::find_by_id($cv_details->recent_career_level);
$rcl = $careers ? $careers->career_name : format_lang('none');
$smarty->assign('careers', $rcl);
//what are you looking for
$ljt = $cv_details->look_job_title;
$smarty->assign('ljt', $ljt);
$ljt2 = $cv_details->look_job_title2;
$smarty->assign('ljt2', $ljt2);
$sql = " SELECT * FROM " . TBL_CV_CAT . " WHERE cv_id=" . $id;
$cv_cat = $db->query($sql);
$cv_cat_array = array();
while ($row = $db->fetch_object($cv_cat)) {
    $categories = Category::find_by_id($row->category_id);
    $cv_cat_array[] = $categories->cat_name;
}
$smarty->assign('li', join("<br />", $cv_cat_array));
//job states
$js = empty($cv_details->look_job_status) ? 0 : $cv_details->look_job_status;
$job_status = JobStatus::find_by_id($js);
$ljs = $job_status ? $job_status->status_name : format_lang('none');
$smarty->assign('ljs', $ljs);
//job type
$job_t = empty($cv_details->look_job_type) ? 0 : $cv_details->look_job_type;
$job_type_arr = JobType::find_by_id($job_t);
//print_r( $job_type_arr);
$job_types = $job_type_arr ? $job_type_arr->type_name : format_lang('none');
$smarty->assign('job_type', $job_types);
//where do you wont to work
开发者ID:nim94sha,项目名称:Online-Job-Portal,代码行数:31,代码来源:review_cv_page.php

示例8: Category

<?php

require_once "../initialise_files.php";
include_once "sessioninc.php";
$smarty->assign('action', $_GET['action']);
$smarty->assign('id', (int) $_GET['id']);
if (isset($_GET['action']) && $_GET['action'] == "edit" && isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $cat_ = Category::find_by_id($id);
    $cat_name = strip_tags($cat_->cat_name);
    $smarty->assign('cat_name', $cat_name);
    if (isset($_GET['bt_update'])) {
        $category = new Category();
        $category->id = (int) $_GET['id'];
        $category->var_name = $category->mod_write_check($_GET['txt_cat_name'], $cat_->var_name);
        $category->cat_name = $_GET['txt_cat_name'];
        if ($category->save()) {
            $session->message("category updated ");
            redirect_to($_SERVER['PHP_SELF'] . "?#" . $_GET['id']);
            die;
        } else {
            $message = join("<br />", $category->errors);
        }
    }
}
if (isset($_GET['action']) && $_GET['action'] == "delete" && isset($_GET['id'])) {
    $category = new Category();
    $category->id = (int) $_GET['id'];
    if ($category->delete()) {
        $session->message("category deleted ");
        redirect_to($_SERVER['PHP_SELF'] . "?#" . $_GET['id']);
开发者ID:nim94sha,项目名称:Online-Job-Portal,代码行数:31,代码来源:view_category.php

示例9: isset

if (isset($_GET[$name])) {
    $value = $_GET[$name];
} else {
    isset($get_item) ? $value = $get_item->{$name} : ($value = $date);
}
echo $class_name::get_form($name, $value);
$name = 'quantity';
if (isset($_GET[$name])) {
    $value = $_GET[$name];
} else {
    isset($get_item) ? $value = $get_item->{$name} : ($value = "1");
}
echo $class_name::get_form($name, $value);
if (isset($_GET['category_id'])) {
    $value_get = $_GET['category_id'];
    $categ = Category::find_by_id($_GET['category_id']);
}
$name = 'unit_price';
if (isset($_GET[$name])) {
    $value = $_GET[$name];
} else {
    isset($get_item) ? $value = $get_item->{$name} : ($value = "");
}
if ($categ) {
    $value = $categ->{$name};
}
echo $class_name::get_form($name, $value);
$name = 'company_unit_price';
if (isset($_GET[$name])) {
    $value = $_GET[$name];
} else {
开发者ID:kamy333,项目名称:rajah,代码行数:31,代码来源:new_invoice_actual.php

示例10: delete

 /**
  * Удаление категории
  */
 public function delete()
 {
     if (!Request::ajax()) {
         App::redirect('/');
     }
     if (!User::isAdmin()) {
         App::abort(403);
     }
     $errors = '';
     $id = Request::input('id');
     if ($category = Category::find_by_id($id)) {
         $category->token = Request::input('token', true);
         if ($category->is_valid() && $category->delete()) {
             exit(json_encode(['status' => 'ok']));
         } else {
             $errors = $category->getErrorsText();
         }
     }
     exit(json_encode(['status' => 'error', 'errors' => $errors]));
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:23,代码来源:CategoryController.php

示例11: getCategoryWeb

 function getCategoryWeb()
 {
     if (isset($_POST['cat_id'])) {
         $category = Category::find_by_id($_POST['cat_id']);
         return $category;
     }
 }
开发者ID:runningjack,项目名称:RobertJohnson,代码行数:7,代码来源:forms_model.php

示例12: deleteProduct

 public function deleteProduct($id)
 {
     $category = Category::find_by_id($id);
     if ($category->delete()) {
         $_SESSION['adminmessage'] == "Deleted Successfully";
         return true;
     } else {
         $_SESSION['adminmessage'] == "Delete not successfully, try again";
         return true;
     }
 }
开发者ID:runningjack,项目名称:RobertJohnson,代码行数:11,代码来源:products_model.php


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