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


PHP Model::field方法代码示例

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


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

示例1: C

 function ajax_arclist()
 {
     $prefix = !empty($_REQUEST['prefix']) ? (bool) $_REQUEST['prefix'] : true;
     //表过滤防止泄露信息,只允许的表
     if (!in_array($_REQUEST['model'], array('article', 'type', 'ad', 'label', 'link'))) {
         exit;
     }
     if (!empty($_REQUEST['model'])) {
         if ($prefix == true) {
             $model = C('DB_PREFIX') . $_REQUEST['model'];
         } else {
             $model = $_REQUEST['model'];
         }
     } else {
         $model = C('DB_PREFIX') . 'article';
     }
     $order = !empty($_REQUEST['order']) ? inject_check($_REQUEST['order']) : '';
     $num = !empty($_REQUEST['num']) ? inject_check($_REQUEST['num']) : '';
     $where = !empty($_REQUEST['where']) ? inject_check(urldecode($_REQUEST['where'])) : '';
     //使where支持 条件判断,添加不等于的判断
     $page = false;
     if (!empty($_REQUEST['page'])) {
         $page = (bool) $_REQUEST['page'];
     }
     $pagesize = !empty($_REQUEST['pagesize']) ? intval($_REQUEST['pagesize']) : '10';
     //$query     =!empty($_REQUEST['sql'])?$_REQUEST['sql']:'';//太危险不用
     $field = '';
     if (!empty($_REQUEST['field'])) {
         $f_t = explode(',', inject_check($_REQUEST['field']));
         $f_t = array_map('urlencode', $f_t);
         $field = implode(',', $f_t);
     }
     $m = new Model($model, NULL);
     //如果使用了分页,缓存也不生效
     if ($page) {
         import("ORG.Util.Page");
         //这里改成你的Page类
         $count = $m->where($where)->count();
         $total_page = ceil($count / $pagesize);
         $p = new Page($count, $pagesize);
         //如果使用了分页,num将不起作用
         $t = $m->field($field)->where($where)->limit($p->firstRow . ',' . $p->listRows)->order($order)->select();
         //echo $m->getLastSql();
         $ret = array('total_page' => $total_page, 'data' => $t);
     }
     //如果没有使用分页,并且没有 query
     if (!$page) {
         $ret = $m->field($field)->where($where)->order($order)->limit($num)->select();
     }
     $this->ajaxReturn($ret, '返回信息', 1);
 }
开发者ID:babyhuangshiming,项目名称:webserver,代码行数:51,代码来源:ApiAction.class.php

示例2: field

 public function field($name, $conditions = null, $order = null)
 {
     if (isset($_SERVER['FORCEMASTER'])) {
         $this->useDbConfig = 'master';
     }
     return parent::field($name, $conditions, $order);
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:7,代码来源:AppModel.php

示例3: addToBasket

 public function addToBasket(Model $Model, $id, array $options = array())
 {
     $options = Hash::merge(array('basket' => $Model->ShoppingBasketItem->ShoppingBasket->currentBasketId(), 'amount' => 1, 'configuration' => array(), 'non_overridable' => array()), array_filter($options));
     $configurationGroupIds = $Model->ItemConfigurationGroup->find('list', array('fields' => array('ConfigurationGroup.id'), 'conditions' => array('ItemConfigurationGroup.foreign_key' => $id, 'ItemConfigurationGroup.model' => $Model->name), 'contain' => array('ConfigurationGroup')));
     $valueData = $Model->ShoppingBasketItem->ConfigurationValue->generateValueData($Model->ShoppingBasketItem->name, $configurationGroupIds, $options['configuration'], $options['non_overridable']);
     $stackable = $Model->field('stackable', array('id' => $id));
     if ($stackable) {
         $shoppingBasketItemId = $Model->ShoppingBasketItem->field('id', array('ShoppingBasketItem.shopping_basket_id' => $options['basket'], 'ShoppingBasketItem.product_id' => $id));
         if (!$shoppingBasketItemId) {
             $Model->ShoppingBasketItem->create();
             $data = $Model->ShoppingBasketItem->saveAssociated(array('ShoppingBasketItem' => array('shopping_basket_id' => $options['basket'], 'product_id' => $id, 'amount' => $options['amount']), 'ConfigurationValue' => $valueData));
             return $data;
         }
         $Model->ShoppingBasketItem->id = $shoppingBasketItemId;
         $amount = $Model->ShoppingBasketItem->field('amount');
         return $Model->ShoppingBasketItem->saveField('amount', $amount + $options['amount']);
     }
     for ($number = 1; $number <= $options['amount']; $number++) {
         $Model->ShoppingBasketItem->create();
         $data = $Model->ShoppingBasketItem->saveAssociated(array('ShoppingBasketItem' => array('shopping_basket_id' => $options['basket'], 'product_id' => $id, 'amount' => 1), 'ConfigurationValue' => $valueData));
         if (!$data) {
             return false;
         }
     }
     return true;
 }
开发者ID:cvo-technologies,项目名称:croogo-webshop-shopping-cart-plugin,代码行数:26,代码来源:CartItemBehavior.php

示例4: moveOrder

 public function moveOrder(Model $model, $data, $conditions = array())
 {
     $id = $data[$model->alias]['id'];
     $idField = $model->alias . '.id';
     $orderField = $model->alias . '.order';
     $move = $data[$model->alias]['move'];
     $order = $model->field('order', array('id' => $id));
     $idConditions = array_merge(array($idField => $id), $conditions);
     $updateConditions = array_merge(array($idField . ' <>' => $id), $conditions);
     $this->fixOrder($model, $conditions);
     if ($move === 'up') {
         $model->updateAll(array($orderField => $order - 1), $idConditions);
         $updateConditions[$orderField] = $order - 1;
         $model->updateAll(array($orderField => $order), $updateConditions);
     } else {
         if ($move === 'down') {
             $model->updateAll(array($orderField => $order + 1), $idConditions);
             $updateConditions[$orderField] = $order + 1;
             $model->updateAll(array($orderField => $order), $updateConditions);
         } else {
             if ($move === 'first') {
                 $model->updateAll(array($orderField => 1), $idConditions);
                 $updateConditions[$orderField . ' <'] = $order;
                 $model->updateAll(array($orderField => $orderField . ' + 1'), $updateConditions);
             } else {
                 if ($move === 'last') {
                     $count = $model->find('count', array('conditions' => $conditions));
                     $model->updateAll(array($orderField => $count), $idConditions);
                     $updateConditions[$orderField . ' >'] = $order;
                     $model->updateAll(array($orderField => $orderField . ' - 1'), $updateConditions);
                 }
             }
         }
     }
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:35,代码来源:ReorderBehavior.php

示例5: deleteOldUpload

 public function deleteOldUpload(Model $model, $field)
 {
     $file = $model->field($field);
     if (empty($file)) {
         return true;
     }
     if (file_exists(WWW_ROOT . $file)) {
         unlink(WWW_ROOT . $file);
     }
 }
开发者ID:eripoll,项目名称:lebiplan,代码行数:10,代码来源:UploaderBehavior.php

示例6: listall

 function listall()
 {
     $projects = new Model('project');
     @($res = $projects->field('project_name,project_desc,project_hash,time,status')->where("user_hash = '" . $_SESSION['user_hash'] . "'")->select());
     //封装数组处理
     $url = new Model('url');
     foreach ($res as $key => &$value) {
         $value['shellnum'] = $url->where("project_hash = '" . $value['project_hash'] . "'")->count();
         $value['time'] = date('Y-m-d', $value['time']);
     }
     return $res;
 }
开发者ID:wuyouzi,项目名称:expweb-v1.0,代码行数:12,代码来源:IndexController.class.php

示例7: afterSave

 public function afterSave(Model $model, $created, $options = array())
 {
     if (!empty($model->data[$model->name]['thumb']['name'])) {
         $file = $model->data[$model->name]['thumb'];
         // Current thumb
         $media_id = $model->field('media_id');
         if ($media_id != 0) {
             $model->Media->delete($media_id);
         }
         // Update thumb
         $model->Media->save(array('ref_id' => $model->id, 'ref' => $model->name, 'file' => $file));
         $model->saveField('media_id', $model->Media->id);
     }
 }
开发者ID:smagic39,项目名称:CakePHP-Media,代码行数:14,代码来源:MediaBehavior.php

示例8: getTask

 public function getTask()
 {
     $objtask = new Model('project');
     $alltask = $objtask->field('project_hash,target,setting')->where("status = 0")->find();
     //处理exp数组
     if ($alltask) {
         $arr = array_merge($alltask, unserialize($alltask['setting']));
         unset($arr['setting']);
         //格式化与加密数据
         //echo str_replace("\\/","/",json_encode($arr));
         echo data_encode(str_replace("\\/", "/", json_encode($arr)), $this->key);
     } else {
         echo 'notask';
     }
 }
开发者ID:wuyouzi,项目名称:expweb-v1.0,代码行数:15,代码来源:ApiController.class.php

示例9: deleteOldUpload

 public function deleteOldUpload(Model $model, $field)
 {
     $file = $model->field($field);
     if (empty($file)) {
         return true;
     }
     $info = pathinfo($file);
     $subfiles = glob(WWW_ROOT . $info['dirname'] . DS . $info['filename'] . '_*x*.*');
     if (file_exists(WWW_ROOT . $file)) {
         unlink(WWW_ROOT . $file);
     }
     if ($subfiles) {
         foreach ($subfiles as $file) {
             unlink($file);
         }
     }
 }
开发者ID:kokomanu31,项目名称:restauration,代码行数:17,代码来源:UploadBehavior.php

示例10: parentNode

 /**
  * parentNode
  *
  * @param Model $model
  * @return array
  */
 public function parentNode($model)
 {
     if (!$model->id && empty($model->data)) {
         return null;
     }
     $data = $model->data;
     if (empty($model->data)) {
         $data = $model->read();
     }
     if (!isset($data['User']['role_id'])) {
         $data['User']['role_id'] = $model->field('role_id');
     }
     if (!isset($data['User']['role_id']) || !$data['User']['role_id']) {
         return null;
     } else {
         return array('Role' => array('id' => $data['User']['role_id']));
     }
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:24,代码来源:UserAroBehavior.php

示例11: delurl

 function delurl()
 {
     $urlhash = _get('get.token', null, '/^[a-z0-9]{30}$/');
     if ($urlhash) {
         //获取项目token
         $obj = new Model('url');
         $tokenarr = $obj->field('project_hash')->where("url_hash = '" . $urlhash . "'")->find();
         $token = $tokenarr['project_hash'];
         //项目token查用户hash权限判断
         $buffusers = new Model('project');
         $userhash = $buffusers->field('user_hash')->where("project_hash = '" . $token . "'")->find();
         if ($userhash['user_hash'] != $_SESSION['user_hash']) {
             exit;
         }
         if ($obj->where("url_hash = '" . $urlhash . "'")->del()) {
             $this->_ajaxReturn('删除成功', 'success', 'index.php?m=project&a=listurl&token=' . $token);
         }
     }
 }
开发者ID:wuyouzi,项目名称:expweb-v1.0,代码行数:19,代码来源:ProjectController.class.php

示例12: check

 public function check()
 {
     $data['usrname'] = _get('post.username', null, '/[a-zA-Z0-9]{4,12}/');
     $data['usrpass'] = _get('post.password');
     $users = new Model('users');
     //用户验证
     if ($usr = $users->field('usrname,usrpass,user_hash')->where("usrname = '" . $data['usrname'] . "'")->find()) {
         if (_md5($data['usrpass'], 'codier', -20) == $usr['usrpass']) {
             //设置用户session
             $_SESSION['isLogin'] = true;
             $_SESSION['user_hash'] = $usr['user_hash'];
             $_SESSION['usrname'] = $usr['usrname'];
             $this->_ajaxReturn('登录成功', 'success', 'index.php?m=index&a=index');
         } else {
             $this->_ajaxReturn('用户名或者密码错误', 'prompt');
         }
     } else {
         $this->_ajaxReturn('用户名或者密码错误', 'prompt');
     }
 }
开发者ID:wuyouzi,项目名称:expweb-v1.0,代码行数:20,代码来源:LoginController.class.php

示例13: increment

 public function increment(Model $Model, $id = null, $field = null)
 {
     if (!$field && key($this->settings[$Model->alias]['fields'])) {
         $field = key($this->settings[$Model->alias]['fields']);
     }
     if (!$field) {
         return false;
     }
     if ($id === null) {
         $id = $Model->getID();
     }
     if ($id === false) {
         return false;
     }
     $Model->id = $id;
     $currentValue = $Model->field($field, array($Model->alias . '.id' => $id));
     $result = $Model->saveField($field, $currentValue + 1);
     if (!$result) {
         return false;
     }
     return $currentValue + 1;
 }
开发者ID:cvo-technologies,项目名称:croogo-webshop-plugin,代码行数:22,代码来源:CounterBehavior.php

示例14: reportedObjectUrl

 /**
  * Generates an array of params to be used in Router::url() to get a link to the reported object view page
  *
  * @param AppModel $Model
  * @param string $id the reported object identifier
  * @return array
  */
 public function reportedObjectUrl(Model $Model, $id)
 {
     $modelName = Configure::read('Problems.Models.' . $Model->alias);
     if ($Model->hasField('slug')) {
         $id = $Model->field('slug', array('id' => $id));
     }
     return array('admin' => false, 'controller' => Inflector::tableize($Model->name), 'action' => 'view', $id, 'plugin' => current(pluginSplit($modelName)));
 }
开发者ID:CakeDC,项目名称:problems,代码行数:15,代码来源:ReportableBehavior.php

示例15: _validateSameHash

 /**
  * PasswordableBehavior::_validateSameHash()
  *
  * @param Model $Model
  * @param string $pwd
  * @return bool Success
  */
 protected function _validateSameHash(Model $Model, $pwd)
 {
     $field = $this->settings[$Model->alias]['field'];
     $type = $this->settings[$Model->alias]['hashType'];
     $salt = $this->settings[$Model->alias]['hashSalt'];
     if ($this->settings[$Model->alias]['authType'] === 'Blowfish') {
         $type = 'blowfish';
         $salt = false;
     }
     $primaryKey = $Model->data[$Model->alias][$Model->primaryKey];
     $dbValue = $Model->field($field, [$Model->primaryKey => $primaryKey]);
     if (!$dbValue && $pwd) {
         return false;
     }
     if ($type === 'blowfish' && function_exists('password_hash') && !empty($this->settings[$Model->alias]['passwordHasher'])) {
         $value = $pwd;
     } else {
         if ($type === 'blowfish') {
             $salt = $dbValue;
         }
         $value = Security::hash($pwd, $type, $salt);
     }
     if ($type === 'blowfish' && function_exists('password_hash') && !empty($this->settings[$Model->alias]['passwordHasher'])) {
         $PasswordHasher = $this->_getPasswordHasher($this->settings[$Model->alias]['passwordHasher']);
         return $PasswordHasher->check($value, $dbValue);
     }
     return $value === $dbValue;
 }
开发者ID:ByMyHandsOnly,项目名称:BMHO_Web,代码行数:35,代码来源:PasswordableBehavior.php


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