示例#1
0
 /**
  * 通过主键,编辑一条记录
  * @param integer|array $value
  * @param array $params
  * @return integer
  */
 public function modifyByPk($value, array $params = array())
 {
     $srv = Service::getInstance('Regions', 'system');
     $columnNames = array('live_country_id' => 'live_country', 'live_province_id' => 'live_province', 'live_city_id' => 'live_city', 'live_district_id' => 'live_district', 'address_country_id' => 'address_country', 'address_province_id' => 'address_province', 'address_city_id' => 'address_city', 'address_district_id' => 'address_district');
     foreach ($columnNames as $columnId => $columnName) {
         if (isset($params[$columnId])) {
             $params[$columnName] = $srv->getRegionNameByRegionId($params[$columnId]);
         }
     }
     if (isset($params['interests'])) {
         if (is_string($params['interests'])) {
             $params['interests'] = explode(',', $params['interests']);
         }
     }
     return parent::modifyByPk($value, $params);
 }
示例#2
0
 /**
  * 调用编辑类方法
  * @param \libsrv\AbstractService $object
  * @param string $method
  * @param integer|array $id
  * @param array $params
  * @return array
  */
 public function callModifyMethod(AbstractService $object, $method, $id, array $params = array())
 {
     $rowCount = $object->{$method}($id, $params);
     $errors = $object->getErrors();
     if ($rowCount === false) {
         if ($errors === array()) {
             $errNo = ErrorNo::ERROR_DB_UPDATE;
             $errMsg = Lang::_('ERROR_MSG_ERROR_DB_UPDATE');
             Log::warning(sprintf('%s callModifyMethod, service "%s", method "%s", id "%s", params "%s"', $errMsg, get_class($object), $method, is_array($id) ? serialize($id) : $id, serialize($params)), $errNo, __METHOD__);
             return array('err_no' => $errNo, 'err_msg' => $errMsg, 'id' => $id);
         }
         $errNo = ErrorNo::ERROR_ARGS_UPDATE;
         $errMsg = Lang::_('ERROR_MSG_ERROR_ARGS_UPDATE');
         Log::warning(sprintf('%s callModifyMethod, service "%s", method "%s", id "%s", params "%s", errors "%s"', $errMsg, get_class($object), $method, is_array($id) ? serialize($id) : $id, serialize($params), serialize($errors)), $errNo, __METHOD__);
         return array('err_no' => $errNo, 'err_msg' => $errMsg, 'id' => $id, 'errors' => $errors);
     }
     $errNo = ErrorNo::SUCCESS_NUM;
     $errMsg = $rowCount > 0 ? Lang::_('ERROR_MSG_SUCCESS_UPDATE') : Lang::_('ERROR_MSG_ERROR_DB_AFFECTS_ZERO');
     Log::debug(sprintf('%s callModifyMethod, service "%s", method "%s", id "%s", rowCount "%d", params "%s"', $errMsg, get_class($object), $method, is_array($id) ? serialize($id) : $id, $rowCount, serialize($params)), $errNo, __METHOD__);
     return array('err_no' => $errNo, 'err_msg' => $errMsg, 'id' => $id, 'row_count' => $rowCount);
 }
示例#3
0
 /**
  * 通过主键,查询一条记录
  * @param integer $groupId
  * @return array
  */
 public function findByPk($groupId)
 {
     $row = parent::findByPk($groupId);
     if (is_array($row) && isset($row['group_id'])) {
         $row['permission'] = unserialize(base64_decode($row['permission']));
         if (!is_array($row['permission'])) {
             $row['permission'] = array();
         }
     }
     return $row;
 }
示例#4
0
 /**
  * 构造方法:初始化分表数字
  * @param integer $tableNum 分表数字,如果 >= 0 表示分表操作
  */
 public function __construct($tableNum = -1)
 {
     parent::__construct();
     $this->_tableNum = (int) $tableNum;
 }
示例#5
0
文件: Posts.php 项目: suyuanen/trotri
 /**
  * (non-PHPdoc)
  * @see \libsrv\AbstractService::modifyByPk()
  */
 public function modifyByPk($value, array $params = array())
 {
     $rowCount = parent::modifyByPk($value, $params);
     if ($rowCount === false) {
         return false;
     }
     $dispatcher = Plugin::getInstance();
     $dispatcher->trigger('onAfterSave', array(__METHOD__, &$params, $value));
     return true;
 }
示例#6
0
文件: Users.php 项目: suyuanen/trotri
 /**
  * (non-PHPdoc)
  * @see \libsrv\AbstractService::modifyByPk()
  */
 public function modifyByPk($value, array $params = array())
 {
     $rowCount = parent::modifyByPk($value, $params);
     if ($rowCount === false) {
         return false;
     }
     $groupIds = $this->getFormProcessor()->group_ids;
     if (is_array($groupIds)) {
         $rowCount = $this->_userGroups->modify($value, $groupIds);
     }
     $dispatcher = Plugin::getInstance();
     $dispatcher->trigger('onAfterSave', array(__METHOD__, &$params, $value));
     return true;
 }
示例#7
0
 /**
  * (non-PHPdoc)
  * @see \libsrv\AbstractService::modifyByPk()
  */
 public function modifyByPk($value, array $params = array())
 {
     $dispatcher = Plugin::getInstance();
     $dispatcher->trigger('onBeforeSave', array(__METHOD__, &$params, $value));
     return parent::modifyByPk($value, $params);
 }