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


PHP Jelly::delete方法代码示例

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


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

示例1: 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

示例2: initialize

 /**
  * Create new model
  *
  * @param  Jelly_Meta  $meta
  */
 public static function initialize(Jelly_Meta $meta)
 {
     $meta->fields(array('id' => new Field_Primary(), 'token' => new Field_String(array('unique' => true, 'rules' => array('max_length' => array(32)))), 'user' => new Field_BelongsTo(), 'user_agent' => new Field_String(), 'created' => new Field_Timestamp(array('auto_now_create' => true)), 'expires' => new Field_Timestamp()));
     // Garbace collection
     if (mt_rand(1, 100) === 1) {
         Jelly::delete('user_token')->where('expires', '<', time())->execute();
     }
 }
开发者ID:netbiel,项目名称:core,代码行数:13,代码来源:token.php

示例3: save

 /**
  * Implementation for Jelly_Field_Behavior_Saveable.
  *
  * @param   Jelly  $model
  * @param   mixed  $value
  * @return  void
  */
 public function save($model, $value, $loaded)
 {
     // Find all current records so that we can calculate what's changed
     $in = $loaded ? $this->_in($model, true) : array();
     // Find old relationships that must be deleted
     if ($old = array_diff($in, (array) $value)) {
         Jelly::delete($this->through['model'])->where($this->through['columns'][0], '=', $model->id())->where($this->through['columns'][1], 'IN', $old)->execute(Jelly::meta($model)->db());
     }
     // Find new relationships that must be inserted
     if (!empty($value) && ($new = array_diff((array) $value, $in))) {
         foreach ($new as $new_id) {
             if (!is_null($new_id)) {
                 Jelly::insert($this->through['model'])->columns($this->through['columns'])->values(array($model->id(), $new_id))->execute(Jelly::meta($model)->db());
             }
         }
     }
 }
开发者ID:netbiel,项目名称:core,代码行数:24,代码来源:manytomany.php

示例4: save

 /**
  * Implementation for Jelly_Field_Behavior_Saveable.
  *
  * @param   Jelly  $model
  * @param   mixed  $value
  * @return  void
  */
 public function save($model, $value, $loaded)
 {
     // Find all current records so that we can calculate what's changed
     $in = $loaded ? $this->_in($model, TRUE) : array();
     // Find old relationships that must be deleted
     if ($old = array_diff($in, (array) $value)) {
         Jelly::delete($this->through['model'])->where($this->through['columns'][0], '=', $model->id())->where($this->through['columns'][1], 'IN', $old)->execute(Jelly::meta($model)->db());
     }
     // Find new relationships that must be inserted
     if ($new = array_diff((array) $value, $in)) {
         foreach ($new as $new_id) {
             // Not sure why an array with NULL as the first value was coming through when you didn't submit anything
             // on the manytomany relationship but this avoids the problem for now...
             if ($new_id == NULL) {
                 continue;
             }
             /*
             				if (class_exists(Jelly::class_name($this->through['model']))) {
             					Jelly::factory(
             						$this->through['model'],
             						array(
             							$this->through['columns'][0] => $model->id(),
             							$this->through['columns'][1] => $new_id
             						)
             					)->save();
             				} else {
             */
             Jelly::insert($this->through['model'])->columns($this->through['columns'])->values(array($model->id(), $new_id))->execute(Jelly::meta($model)->db());
             //}
         }
     }
 }
开发者ID:vitch,项目名称:kohana-jelly,代码行数:39,代码来源:manytomany.php

示例5: delete

 /**
  * Deletes a single record.
  *
  * @param   $key  A key to use for non-loaded records
  * @return  boolean
  **/
 public function delete($key = NULL)
 {
     $result = FALSE;
     // Are we loaded? Then we're just deleting this record
     if ($this->_loaded or $key) {
         if ($this->_loaded) {
             $key = $this->id();
         }
         $result = Jelly::delete($this)->where(':unique_key', '=', $key)->execute();
     }
     // Clear the object so it appears deleted anyway
     $this->clear();
     return (bool) $result;
 }
开发者ID:jerfowler,项目名称:kohana-jelly,代码行数:20,代码来源:core.php

示例6: delete

 /**
  * Deletes a single record.
  *
  * @param   $key  A key to use for non-loaded records
  * @return  boolean
  **/
 public function delete($key = NULL)
 {
     $result = FALSE;
     // Are we loaded? Then we're just deleting this record
     if ($this->_loaded or $key) {
         if ($this->_loaded) {
             $key = $this->id();
         }
         // Call delete on each individual field so they can clean up after themselves
         foreach ($this->_meta->fields() as $field) {
             $field->delete($this);
         }
         $result = Jelly::delete($this)->where(':unique_key', '=', $key)->execute();
     }
     // Clear the object so it appears deleted anyway
     $this->clear();
     return (bool) $result;
 }
开发者ID:vitch,项目名称:kohana-jelly,代码行数:24,代码来源:core.php

示例7: logout

 /**
  * Log a user out and remove any auto-login Cookies.
  *
  * @param   boolean  completely destroy the session
  * @param	boolean  remove all tokens for user
  * @return  boolean
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     if ($token = Cookie::get('authautologin')) {
         // Delete the autologin Cookie to prevent re-login
         Cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = Jelly::select('user_token')->where('token', '=', $token)->limit(1)->load();
         if ($token->loaded() and $logout_all) {
             Jelly::delete('user_token')->where('user_id', '=', $token->user->id)->execute();
         } elseif ($token->loaded()) {
             $token->delete();
         }
     }
     return parent::logout($destroy);
 }
开发者ID:balkin,项目名称:kohanut-core,代码行数:22,代码来源:jelly.php

示例8: logout

 /**
  * Log out a user by removing the related session variables.
  *
  * @param   boolean  $destroy     Completely destroy the session
  * @param   boolean  $logout_all  Logout all browsers
  * @return  boolean
  */
 public function logout($destroy = false, $logout_all = false)
 {
     // Delete the autologin cookie to prevent re-login
     if ($token = Cookie::get($this->_config['cookie_name'])) {
         Cookie::delete($this->_config['cookie_name']);
         $token = Jelly::select('user_token')->where('token', '=', $token)->limit(1)->load();
         if ($token->loaded() && $logout_all) {
             Jelly::delete('user_token')->where('user_id', '=', $token->user->id)->execute();
         } else {
             if ($token->loaded()) {
                 $token->delete();
             }
         }
     }
     // Logout 3rd party?
     /*
     if (FB::enabled() && Visitor::instance()->get_provider()) {
     	$this->session->delete($this->config['session_key'] . '_provider');
     	try {
     		FB::instance()->expire_session();
     	} catch (Exception $e) { }
     }
     */
     // Destroy the session completely?
     if ($destroy === true) {
         $this->_session->destroy();
     } else {
         // Remove the user from the session
         $this->_session->delete($this->_config['session_key']);
         // Regenerate session_id
         $this->_session->regenerate();
     }
     // Double check
     return !$this->logged_in();
 }
开发者ID:netbiel,项目名称:core,代码行数:42,代码来源:visitor.php


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