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


PHP Jelly::select方法代码示例

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


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

示例1: before

 public function before()
 {
     parent::before();
     // Save the old action so it can be brought back on after
     $this->_action = $this->request->action;
     // Set the current action
     $current_action = $this->request->action;
     $id = $this->request->param('id', NULL);
     // Let's guess the action based on the params
     if (!in_array($this->request->action, array('edit', 'add', 'delete')) and (!is_null($id) or !empty($id))) {
         $current_action = 'read';
     }
     if (!method_exists($this, 'action_' . $this->request->action)) {
         $model = Jelly::select(Inflector::singular($this->request->controller));
         foreach ($model->get_state() as $key => $value) {
             $param = $this->request->param($key, NULL);
             if (!is_null($param)) {
                 $model->set_state($key, $param);
             }
         }
         $this->request->response = Kostache::factory($this->request->controller . '/' . $current_action)->set_model($model);
         // Since the magic has been executed, just execute an empty action
         $this->request->action = 'default';
     }
 }
开发者ID:raeldc,项目名称:kojo-plugin,代码行数:25,代码来源:controller.php

示例2: action_delete

 public function action_delete($id)
 {
     $post = Jelly::select('forum_post')->where('id', '=', $id)->load();
     if ($post->loaded()) {
         $this->title = 'Forum - Post - Delete';
     } else {
         Message::set(Message::ERROR, 'Post does not exist');
         $this->request->redirect('forum');
     }
     if ($this->user->id != $post->user->id) {
         Message::set(Message::ERROR, 'You are not the author of this post.');
         $this->request->redirect('forum');
     } else {
         $topic = Jelly::select('forum_topic')->where('id', '=', $post->topic->id)->load();
         if ($topic->posts > 1) {
             $topic->posts = $topic->posts - 1;
             $topic->save();
             $post->delete();
             Message::set(Message::SUCCESS, 'Post has been deleted.');
             $this->request->redirect('forum');
         }
         if ($topic->posts == 1) {
             $topic->delete();
             $post->delete();
             Message::set(Message::SUCCESS, 'Post has been deleted.');
             $this->request->redirect('forum');
         }
     }
     $this->template->content = View::factory('forum/post/delete')->set('post', $post);
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:30,代码来源:post.php

示例3: action_reply

 /**
  * Create a new post.
  */
 public function action_reply($id)
 {
     $topic = Jelly::select('forum_topic')->where('id', '=', $id)->load();
     // Make sure the topic exists
     if (!$topic->loaded()) {
         Message::set(Message::ERROR, 'Topic does not exist');
         $this->request->redirect('forum');
     }
     $this->title = 'Forum - Reply to ' . $topic->title;
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->filter(TRUE, 'htmlspecialchars', array(ENT_QUOTES))->rule('title', 'not_empty')->rule('title', 'min_length', array(3))->rule('title', 'max_length', array(20))->rule('content', 'not_empty')->rule('content', 'min_length', array(5))->rule('content', 'max_length', array(1000));
     if ($post->check()) {
         $values = array('title' => $post['title'], 'content' => $post['content'], 'user' => $this->user->id, 'topic' => $id);
         $message = Jelly::factory('forum_post');
         // Assign the validated data to the Jelly object
         $message->set($values);
         $message->save();
         $topic_id = $id;
         $topic = Jelly::select('forum_topic')->where('id', '=', $topic_id)->load();
         $topic->posts = $topic->posts + 1;
         $topic->save();
         Message::set(Message::SUCCESS, 'You posted a new reply.');
         $this->request->redirect('forum/topic/' . $id);
     } else {
         $this->errors = $post->errors('forum');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('forum/post/create')->set('post', $post->as_array());
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:34,代码来源:topic.php

示例4: action_update

 public function action_update()
 {
     $this->content->bind('form', $supply);
     $this->content->bind('errors', $errors);
     $id = $this->request->param('id');
     $supply = Jelly::select('supply', $id);
     $supply->set('product', $supply->product);
     // bez tego nie dziala, lol
     if (!$supply->loaded()) {
         $this->request->redirect($this->_base);
     }
     if ($_POST and !$this->session->get($_POST['seed'], FALSE)) {
         if (in_array($supply->status, array('done'))) {
             unset($_POST['status']);
         }
         if (!in_array($supply->status, array('added'))) {
             unset($_POST['quantity'], $_POST['supplier']);
         }
         try {
             $supply->set($_POST);
             $supply->save();
             $this->session->set($_POST['seed'], TRUE);
             // 'seed' jest zintegrowany w formularz
             $this->request->redirect($this->_base);
         } catch (Validate_Exception $e) {
             $errors = $e->errors();
         }
     }
 }
开发者ID:TdroL,项目名称:hurtex,代码行数:29,代码来源:supplies.php

示例5: action_register

 public function action_register()
 {
     if ($this->user) {
         Request::instance()->redirect('');
     }
     // Experimental facebook connection
     $this->facebook = new Fb();
     // User accessed from facebook!
     if ($this->facebook->validate_fb_params()) {
         $this->facebook->require_frame();
         $_SESSION['fb_uid'] = $this->facebook->require_login();
     } elseif (!isset($_SESSION['fb_uid'])) {
         Request::instance()->redirect('');
     }
     // Check if the user got an account.
     $user_facebook = Jelly::select('user_facebook')->where('facebook_id', '=', $_SESSION['fb_uid'])->load();
     // If we found it, log him in.
     if ($user_facebook->loaded()) {
         $this->a1->force_login($user_facebook->user->username);
         $_SESSION['facebook'] = 'TRUE';
         // Used for verifying if logged in using facebook.
         Request::instance()->redirect('');
     }
     $user = Jelly::factory('user');
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('username', 'not_empty')->rule('username', 'min_length', array(3))->rule('username', 'max_length', array(20))->rule('username', 'alpha_numeric')->rule('email', 'email')->rule('tos', 'not_empty');
     if ($post->check()) {
         $values = array('username' => $post['username'], 'email' => $post['email']);
         // Assign the validated data to the sprig object
         $user->set($values);
         // Hash the password
         $user->password = '';
         // Set the default role for registered user.
         $user->role = 'facebook';
         try {
             // Create the new user
             $testy = $user->save();
             //print_r($testy);
             $user_id = mysql_insert_id();
             $ufb = Jelly::factory('user_facebook');
             $ufb->facebook_id = $_SESSION['fb_uid'];
             $ufb->user = $user_id;
             $ufb->save();
             $this->a1->force_login($values['username']);
             $_SESSION['facebook'] = 'TRUE';
             // Used for verifying if logged in using facebook.
             // Redirect the user to the login page
             $this->request->redirect('');
         } catch (Validate_Exception $e) {
             // Get the errors using the Validate::errors() method
             $this->errors = $e->array->errors('register');
         }
     } else {
         $this->errors = $post->errors('account/register');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('facebook/register')->set('post', $post->as_array());
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:60,代码来源:facebook.php

示例6: input

 /**
  * Displays a selection of models to relate to
  *
  * @param   string  $prefix  The prefix to put before the filename to be rendered
  * @return  View
  **/
 public function input($prefix = 'jelly/field', $data = array())
 {
     if (!isset($data['options'])) {
         $data['options'] = Jelly::select($this->foreign['model'])->execute()->as_array(':primary_key', ':name_key');
     }
     return parent::input($prefix, $data);
 }
开发者ID:rcapp,项目名称:kohana-jelly,代码行数:13,代码来源:relationship.php

示例7: action_travel

 /**
  * Moves the character to a new zone
  * 
  * @param  integer  $id
  */
 public function action_travel($id)
 {
     // Make sure id is an integer.
     if (!is_numeric($id)) {
         Message::set(Message::ERROR, 'Invalid ID');
         $this->request->redirect('travel');
     }
     if ($id == $this->character->zone->id) {
         Message::set(Message::ERROR, 'You cannot move to where you already are.');
         $this->request->redirect('travel');
     }
     // Load the zone
     $zone = Jelly::select('zone')->where('id', '=', $id)->load();
     $character = $this->character;
     // Make sure the character got enough of engery
     if ($character->energy < $zone->energy) {
         Message::set(Message::ERROR, 'Not enough energy.');
         $this->request->redirect('travel');
     }
     // Set the new zone, and energy
     $character->zone = $zone->id;
     $character->energy = $character->energy - $zone->energy;
     $character->save();
     $this->request->redirect('character');
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:30,代码来源:travel.php

示例8: action_new_topic

 /**
  * Create a new topic.
  */
 public function action_new_topic($id)
 {
     $this->title = 'Forum - New Topic';
     $category = Jelly::select('forum_category')->where('id', '=', $id)->load();
     if (!$category->loaded()) {
         Message::set(Message::ERROR, 'Category does not exist');
         $this->request->redirect('forum');
     }
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->filter(TRUE, 'htmlspecialchars', array(ENT_QUOTES))->rule('title', 'not_empty')->rule('title', 'min_length', array(3))->rule('title', 'max_length', array(20))->rule('content', 'not_empty')->rule('content', 'min_length', array(5))->rule('content', 'max_length', array(1000));
     if ($post->check()) {
         $topic_values = array('title' => $post['title'], 'user' => $this->user->id, 'category' => $id, 'status' => 'open', 'posts' => '1');
         $topic = Jelly::factory('forum_topic');
         // Assign the validated data to the sprig object
         $topic->set($topic_values);
         $topic->save();
         $topic_id = $topic->id;
         $post_values = array('title' => $post['title'], 'content' => $post['content'], 'user' => $this->user->id, 'topic' => $topic_id);
         $message = Jelly::factory('forum_post');
         // Assign the validated data to the sprig object
         $message->set($post_values);
         $message->save();
         Message::set(Message::SUCCESS, 'You created a topic.');
         $this->request->redirect('forum/category/' . $id);
     } else {
         $this->errors = $post->errors('forum');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('forum/topic/create')->set('post', $post->as_array());
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:35,代码来源:category.php

示例9: action_all

 public function action_all(Params $param)
 {
     $this->content->bind('projects', $projects);
     $projects = Jelly::select('project');
     $this->template->title = __('My works');
     $this->template->active = array('portfolio' => ' class="active"');
 }
开发者ID:TdroL,项目名称:piotrszkaluba.pl,代码行数:7,代码来源:category.php

示例10: input

 public function input($prefix = 'jelly/field', $data = array())
 {
     if (!isset($data['options'])) {
         $data['options'] = Jelly::select($this->foreign['model'])->join('products_suppliers', 'LEFT')->on('products_suppliers.supplier_id', '=', $this->foreign['model'] . ':primary_key')->where('products_suppliers.product_id', '=', $this->product->id)->execute()->as_array($this->foreign['model'] . ':primary_key', $this->foreign['model'] . ':name_key');
     }
     return parent::input($prefix, $data);
 }
开发者ID:TdroL,项目名称:hurtex,代码行数:7,代码来源:supplier.php

示例11: init

 public static function init()
 {
     //get list of all registered modules
     self::$_modules = Jelly::select('module')->execute()->as_array('name');
     //Jx_Debug::dump(self::$_modules,'module listing');
     $paths = array();
     //go through the modules directory and get directory names
     $iter = new DirectoryIterator(MODPATH);
     foreach ($iter as $f) {
         if (!$f->isDot() && $f->isDir()) {
             //compare with registered modules
             $fname = $f->getFilename();
             if (self::isRegistered($fname)) {
                 if (self::isActivated($fname) && !self::isPermanent($fname)) {
                     //if registered, activated, and not permanent, run init.php for the module
                     //permanent modules are initialized by Kohana directly.
                     $path = MODPATH . $fname;
                     $paths[] = realpath(MODPATH . $fname) . DS;
                 }
             } else {
                 self::register($fname);
             }
         }
     }
     Kohana::addPaths($paths);
     foreach ($paths as $path) {
         if (is_file($path . 'init.php')) {
             require_once $path . 'init.php';
         }
     }
 }
开发者ID:jonlb,项目名称:JxCMS,代码行数:31,代码来源:modules.php

示例12: submit

 protected function submit($task, $id, $type)
 {
     $item = Jelly::select($type, $id);
     $redirect = HTML::uri(array('action' => Inflector::plural($type)));
     switch ($task) {
         case 'apply':
             $item->set($_POST)->save();
             $redirect = HTML::uri(array('action' => $type, 'task' => 'edit', 'id' => $item->id));
             $this->request->redirect($redirect);
             break;
         case 'save':
             $item->set($_POST)->save();
             $this->request->redirect($redirect);
             break;
         case 'cancel':
             $this->request->redirect($redirect);
             break;
         case 'delete':
             if ($ids = Arr::get($_POST, 'cid', NULL)) {
                 $items = Jelly::delete($item)->where(':primary_key', 'IN', $ids)->execute();
             }
             $this->request->redirect($redirect);
             break;
         case 'default':
             if (!$item->loaded()) {
                 $this->request->redirect($redirect);
             }
             break;
     }
     return $item;
 }
开发者ID:raeldc,项目名称:kojo-klibrary,代码行数:31,代码来源:library.php

示例13: action_edit

 public function action_edit()
 {
     $this->require_login();
     $this->init_template('Update profile');
     $model = $this->auth->get_user();
     $model = Jelly::select('kadmium_user', $model->id());
     $this->show_edit_page_from_model('Profile', $model, false);
 }
开发者ID:vitch,项目名称:kohana-kadmium,代码行数:8,代码来源:user.php

示例14: _load_user

 /**
  * Loads the user object from database using username
  *
  * @param   string   username
  * @return  object   User Object
  */
 protected function _load_user($username)
 {
     $query = Jelly::select($this->_config['user_model'])->where($this->_config['columns']['username'], '=', $username);
     if (isset($this->_config['columns']['active'])) {
         $query = $query->where($this->_config['columns']['active'], '=', TRUE);
     }
     return $query->limit(1)->execute();
 }
开发者ID:wouterrr,项目名称:a1,代码行数:14,代码来源:Jelly.php

示例15: testIssue87

 /**
  * Tests that models in a collection aren't returned as references to the original
  * object but as a distinct model.
  */
 public function testIssue87()
 {
     $last = NULL;
     foreach (Jelly::select('post')->execute() as $post) {
         $this->assertNotEquals($post, $last);
         $last = $post;
     }
 }
开发者ID:jonathangeiger,项目名称:jelly-tests,代码行数:12,代码来源:Issues.php


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