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


PHP ORM::factory方法代码示例

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


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

示例1: parse_url

 static function parse_url()
 {
     if (Router::$controller) {
         return;
     }
     // Work around problems with the CGI sapi by enforcing our default path
     if ($_SERVER["SCRIPT_NAME"] && "/" . Router::$current_uri == $_SERVER["SCRIPT_NAME"]) {
         Router::$controller_path = MODPATH . "gallery/controllers/albums.php";
         Router::$controller = "albums";
         Router::$method = 1;
         return;
     }
     $current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES);
     $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find();
     if (!$item->loaded) {
         // It's possible that the relative path cache for the item we're looking for is out of date,
         // so find it the hard way.
         $count = count(Router::$segments);
         foreach (ORM::factory("item")->where("name", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES))->where("level", $count + 1)->find_all() as $match) {
             if ($match->relative_path() == $current_uri) {
                 $item = $match;
             }
         }
     }
     if ($item && $item->loaded) {
         Router::$controller = "{$item->type}s";
         Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
         Router::$method = $item->id;
     }
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:30,代码来源:MY_url.php

示例2: action_index

 public function action_index()
 {
     $photos = ORM::factory('Storage')->where('publication_id', '>', '0')->find_all();
     foreach ($photos as $photo) {
         if ($photo->publication_type == 'news') {
             $news = ORM::factory('News', $photo->publication_id);
             if ($news->loaded()) {
                 $title = $news->title;
             }
         } elseif ($photo->publication_type == 'leader') {
             $page = ORM::factory('Leader', $photo->publication_id);
             if ($page->loaded()) {
                 $title = $page->name;
             }
         } else {
             $page = ORM::factory('Pages_content', $photo->publication_id);
             if ($page->loaded()) {
                 $title = $page->name;
             }
         }
         if (!isset($title)) {
             $title = I18n::get("This publication is absent");
         }
         $photo_arr[] = array('date' => $photo->date, 'path' => $photo->file_path, 'publication_id' => $photo->publication_id, 'type' => $photo->publication_type, 'title' => $title);
     }
     $this->set('photos', $photo_arr);
     $this->add_cumb('Photos', '/');
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:28,代码来源:Photos.php

示例3: before

 public function before()
 {
     if ($this->auto_render) {
         $hostArr = explode('.', $_SERVER['HTTP_HOST']);
         $preDomain = $hostArr[0];
         $site = ORM::factory('Site')->where('domain', '=', $preDomain)->find();
         if ($site->loaded()) {
             $this->siteId = $site->id;
             $this->category = ORM::factory('Category')->getAll($site->id, Model_Category::STATUS_SHOW);
             $site = $site->as_array();
             $site['logo'] = '/media/image/data/' . $site['logo'];
             $site['category'] = $this->category;
             $site['author'] = '简站(Simple-Site.cn) - 免费建站、微信网站、免费微信网站!';
             $site['copyright'] = 'Copyright © 2015 SimpleSite. All Rights Reserved';
             $site['friendLinks'] = ORM::factory('FriendLink')->getAll($site['id']);
             $this->theme = "themes/{$site['theme']}/";
             $this->template = View::factory($this->theme . 'base');
             foreach ($site as $key => $value) {
                 View::bind_global($key, $site[$key]);
             }
         } else {
             echo '404';
             exit;
         }
     }
 }
开发者ID:wangyandong,项目名称:SimpleSite,代码行数:26,代码来源:Base.php

示例4: after_submit

 public function after_submit()
 {
     Email::send($this->get_field('email')->get_value()->get_raw(), array('o.zgolich@gmail.com', 'zgol-web.by'), $this->get_field('subject')->get_value()->get_raw(), $this->get_field('answer')->get_value()->get_raw(), TRUE);
     $model = ORM::factory('Feedback')->where('id', '=', $this->_model->id)->find();
     $model->answers++;
     $model->save();
 }
开发者ID:ariol,项目名称:adminshop,代码行数:7,代码来源:Answer.php

示例5: documents

 public static function documents(array $data = array())
 {
     if ($data) {
         $document = ORM::factory('document')->join('documents_courses')->on('documents.id', '=', 'documents_courses.document_id')->join('documents_roles')->on('documents.id', '=', 'documents_roles.document_id');
         if (isset($data['filter_by']) && $data['filter_by']) {
             $document->join('users')->on('documents.user_id', '=', 'users.id');
         }
         if (isset($data['course'])) {
             $course = $data['course'] instanceof Model_Course ? $data['course'] : ORM::factory('course', (int) $data['course']);
             $document->where('documents_courses.course_id', '=', $course->id);
         }
         if (isset($data['role'])) {
             $role = $data['role'] instanceof Model_Role ? $data['role'] : ORM::factory('role', (int) $data['role']);
             $document->where('documents_roles.role_id', '=', $role->id);
         }
         if (isset($data['filter_title']) && $data['filter_title']) {
             $document->where('documents.title', 'LIKE', '%' . $data['filter_title'] . '%');
         }
         if (isset($data['filter_by']) && $data['filter_by']) {
             $document->where('users.firstname', 'LIKE', '%' . $data['filter_by'] . '%');
         }
         $document->group_by('documents.id');
         return $document->find_all();
     } else {
         return ORM::factory('document')->find_all();
     }
 }
开发者ID:hemsinfotech,项目名称:kodelearn,代码行数:27,代码来源:document.php

示例6: create

 /**
  * Create a new comment.
  * @param Item_MOdel $item         the parent item
  * @param User_Model $author       the author User_Model
  * @param string     $text         comment body
  * @param string     $guest_name   guest's name (if the author is a guest user, default empty)
  * @param string     $guest_email  guest's email (if the author is a guest user, default empty)
  * @param string     $guest_url    guest's url (if the author is a guest user, default empty)
  * @return Comment_Model
  */
 static function create($item, $author, $text, $guest_name = null, $guest_email = null, $guest_url = null)
 {
     $comment = ORM::factory("comment");
     $comment->author_id = $author->id;
     $comment->guest_email = $guest_email;
     $comment->guest_name = $guest_name;
     $comment->guest_url = $guest_url;
     $comment->item_id = $item->id;
     $comment->text = $text;
     $comment->state = "published";
     // These values are useful for spam fighting, so save them with the comment.
     $input = Input::instance();
     $comment->server_http_accept = substr($input->server("HTTP_ACCEPT"), 0, 128);
     $comment->server_http_accept_charset = substr($input->server("HTTP_ACCEPT_CHARSET"), 0, 64);
     $comment->server_http_accept_encoding = substr($input->server("HTTP_ACCEPT_ENCODING"), 0, 64);
     $comment->server_http_accept_language = substr($input->server("HTTP_ACCEPT_LANGUAGE"), 0, 64);
     $comment->server_http_connection = substr($input->server("HTTP_CONNECTION"), 0, 64);
     $comment->server_http_host = substr($input->server("HTTP_HOST"), 0, 64);
     $comment->server_http_referer = substr($input->server("HTTP_REFERER"), 0, 255);
     $comment->server_http_user_agent = substr($input->server("HTTP_USER_AGENT"), 0, 128);
     $comment->server_query_string = substr($input->server("QUERY_STRING"), 0, 64);
     $comment->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 32);
     $comment->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 64);
     $comment->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16);
     $comment->save();
     return $comment;
 }
开发者ID:Okat,项目名称:gallery3,代码行数:37,代码来源:comment.php

示例7: _execute

 /**
  * Task to run pending migrations
  *
  * @return null
  */
 protected function _execute(array $params)
 {
     $migrations = new MigrationManager();
     Database::$default = $params['db'];
     $this->db = Database::instance();
     $db_config = Kohana::$config->load('database')->{$params['db']};
     if (!ORM::factory('Migration')->is_installed()) {
         /**
          * Get platform from database config
          */
         $platform = strtolower($db_config['type']);
         if ('mysqli' == $platform) {
             $platform = 'mysql';
         }
         /**
          * Get SQL from file for selected platform
          */
         $file = realpath(substr(__DIR__, 0, strlen(__DIR__) - strlen('classes/Task/Db')) . 'sql/' . $platform . '.sql');
         $handle = fopen($file, 'rb');
         $sql_create = fread($handle, filesize($file));
         $this->db->query(0, $sql_create);
         $msg = Minion_CLI::color("-----------------------------\n", 'green');
         $msg .= Minion_CLI::color("| Migration table create!!! |\n", 'green');
         $msg .= Minion_CLI::color("-----------------------------\n", 'green');
         Minion_CLI::write($msg);
     }
     $migrations->migrate($params['db'], $params['step']);
 }
开发者ID:rafis,项目名称:migrations,代码行数:33,代码来源:Migrate.php

示例8: create_comment_for_user_test

 public function create_comment_for_user_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $admin = user::lookup(2);
     $comment = comment::create($root, $admin, "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $this->assert_equal($admin->full_name, $comment->author_name());
     $this->assert_equal($admin->email, $comment->author_email());
     $this->assert_equal($admin->url, $comment->author_url());
     $this->assert_equal("text_{$rand}", $comment->text);
     $this->assert_equal(1, $comment->item_id);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
     $this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
     $this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
     $this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
     $this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
     $this->assert_equal("HTTP_HOST", $comment->server_http_host);
     $this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("QUERY_STRING", $comment->server_query_string);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
     $this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
     $this->assert_true(!empty($comment->created));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:27,代码来源:Comment_Helper_Test.php

示例9: album_menu

 static function album_menu($menu, $theme)
 {
     $descendants_count = ORM::factory("item", $theme->item()->id)->descendants_count(array("type" => "photo"));
     if ($descendants_count > 1) {
         $menu->append(Menu::factory("link")->id("slideshow")->label(t("View slideshow"))->url("javascript:cooliris.embed.show(" . "{maxScale:0,feed:'" . self::_feed_url($theme) . "'})")->css_id("g-slideshow-link"));
     }
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:7,代码来源:slideshow_event.php

示例10: __get

 /**
  * Overload ORM::__get to support "parent" and "children" properties.
  *
  * @param   string  column name
  * @return  mixed
  */
 public function __get($column)
 {
     if ($column === 'parent') {
         if (empty($this->related[$column])) {
             // Load child model
             $model = ORM::factory(inflector::singular($this->children));
             if (array_key_exists($this->parent_key, $this->object)) {
                 // Find children of this parent
                 $model->where($model->primary_key, $this->object[$this->parent_key])->find();
             }
             $this->related[$column] = $model;
         }
         return $this->related[$column];
     } elseif ($column === 'children') {
         if (empty($this->related[$column])) {
             $model = ORM::factory(inflector::singular($this->children));
             if ($this->children === $this->table_name) {
                 // Load children within this table
                 $this->related[$column] = $model->where($this->parent_key, $this->object[$this->primary_key])->find_all();
             } else {
                 // Find first selection of children
                 $this->related[$column] = $model->where($this->foreign_key(), $this->object[$this->primary_key])->where($this->parent_key, NULL)->find_all();
             }
         }
         return $this->related[$column];
     }
     return parent::__get($column);
 }
开发者ID:kjgarza,项目名称:ushahidi,代码行数:34,代码来源:ORM_Tree.php

示例11: edit

 public function edit()
 {
     if (isset($_POST['save'])) {
         $post = new Validation(array_merge($_POST, $_FILES));
         //********  TO DO: trim for shipping info     **************/
         $post->pre_filter('trim', 'msg_text1', 'designpath', 'img_approved');
         $post->add_rules('msg_text1', 'required');
         $post->add_rules('designpath', 'required', 'numeric');
         $post->add_rules('img_approved', 'numeric');
         if (!$post->validate()) {
             $errors = $post->errors('form_errors');
             foreach ($errors as $error) {
                 echo '<p class="error">' . $error . '</p>';
             }
         } else {
             $id = $this->uri->segment(3);
             $basket = ORM::factory('orders_basket')->find($id);
             $basket->msg_text1 = $post->msg_text1;
             $basket->designpath = $post->designpath;
             $basket->img_approved = $post->img_approved;
             $basket->save();
             /*************** TO DO: delete more than one category ****************/
         }
     }
     $this->_renderView();
 }
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:26,代码来源:orders_baskets.php

示例12: __construct

 public function __construct()
 {
     parent::__construct('taxon_designation', 'taxon_designation/index');
     $this->columns = array('id' => '', 'title' => '', 'category' => '');
     $this->pagetitle = "Taxon Designations";
     $this->model = ORM::factory('taxon_designation');
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:7,代码来源:taxon_designation.php

示例13: get

 /**
  * Выборка меты
  *
  * @static
  * @param string $mask
  * @param array $params
  * @param boolean $colums == TRUE выбирается meta+title
  * @param boolean $colums == FALSE выбирается h1
  * @param boolean $colums == NULL выбирается всё
  * @return array
  */
 public static function get($mask, array $params = array(), $colums = NULL)
 {
     if (($data = self::$_data_cache) == NULL) {
         $data = ORM::factory('meta')->where('page.name', '=', $mask)->find_all();
         self::$_data_cache = $data;
     }
     $meta = array();
     foreach ($data as $item) {
         $html = $item->type->scheme;
         $html = str_replace('{%value%}', $item->data, $html);
         $meta[$item->type->tag] = $html;
     }
     foreach ($params as $key => $item) {
         unset($params[$key]);
         $key = '{%' . $key . '%}';
         $params[$key] = $item;
     }
     foreach ($meta as &$value) {
         $value = strtr($value, $params);
     }
     if ($colums === TRUE) {
         if (isset($meta['h1'])) {
             unset($meta['h1']);
         }
     } elseif ($colums === FALSE) {
         $header = NULL;
         if (isset($meta['h1'])) {
             $header = $meta['h1'];
         }
         return $header;
     }
     self::$_meta = $meta;
     return $meta;
 }
开发者ID:nergal,项目名称:kohana-libs,代码行数:45,代码来源:meta.php

示例14: _show

 private function _show($album)
 {
     $page_size = module::get_var("gallery", "page_size", 9);
     $page = Input::instance()->get("page", "1");
     $album_defn = unserialize(module::get_var("dynamic", $album));
     $children_count = $album_defn->limit;
     if (empty($children_count)) {
         $children_count = ORM::factory("item")->viewable()->where("type", "!=", "album")->count_all();
     }
     $offset = ($page - 1) * $page_size;
     $max_pages = ceil($children_count / $page_size);
     // Make sure that the page references a valid offset
     if ($page < 1 || $children_count && $page > ceil($children_count / $page_size)) {
         throw new Kohana_404_Exception();
     }
     $template = new Theme_View("page.html", "collection", "dynamic");
     $template->set_global("page", $page);
     $template->set_global("page_size", $page_size);
     $template->set_global("max_pages", $max_pages);
     $template->set_global("children", ORM::factory("item")->viewable()->where("type", "!=", "album")->order_by($album_defn->key_field, "DESC")->find_all($page_size, $offset));
     $template->set_global("children_count", $children_count);
     $template->content = new View("dynamic.html");
     $template->content->title = t($album_defn->title);
     print $template;
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:25,代码来源:dynamic.php

示例15: action_add

 /**
  * Add new action
  */
 public function action_add()
 {
     $data = array();
     //get all sys controller available
     $controllers = ORM::factory('SysController')->find_all();
     $_c = array();
     foreach ($controllers as $ctl) {
         $_c[$ctl->id] = $ctl->name;
     }
     $data['controllers'] = $_c;
     unset($_c);
     unset($controllers);
     //if page is post back
     if ($_POST) {
         $controlder_id = $_POST['controller'];
         $_sysA = new Model_SysAction();
         $post = $_sysA->validate_create($_POST);
         if ($post->check()) {
             $_sysA->values($post);
             $controller = new Model_SysController($controlder_id);
             $_sysA->controller = $controller;
             $_sysA->save_create();
             Request::instance()->redirect('sysaction/index');
         } else {
             $data['errors'] = $post->errors('sysaction/add');
             #Repopulate $_POST data
             $_POST = $post->as_array();
             //fix not show selected index after post
             $_POST['controller'] = $controlder_id;
         }
     }
     $this->template->title = 'Add Action in Controller';
     $view = View::factory('pages/sysaction/add', $data);
     $this->template->content = $view->render();
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:38,代码来源:sysaction.php


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