本文整理汇总了PHP中IModel::getObj方法的典型用法代码示例。如果您正苦于以下问题:PHP IModel::getObj方法的具体用法?PHP IModel::getObj怎么用?PHP IModel::getObj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModel
的用法示例。
在下文中一共展示了IModel::getObj方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* @brief 商家登录动作
*/
public function login()
{
$seller_name = IFilter::act(IReq::get('username'));
$password = IReq::get('password');
$message = '';
if ($seller_name == '') {
$message = '登录名不能为空';
} else {
if ($password == '') {
$message = '密码不能为空';
} else {
$sellerObj = new IModel('seller');
$sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0');
if ($sellerRow && $sellerRow['password'] == md5($password)) {
$dataArray = array('login_time' => ITime::getDateTime());
$sellerObj->setData($dataArray);
$where = 'id = ' . $sellerRow["id"];
$sellerObj->update($where);
//存入私密数据
ISafe::set('seller_id', $sellerRow['id']);
ISafe::set('seller_name', $sellerRow['seller_name']);
ISafe::set('seller_pwd', $sellerRow['password']);
$this->redirect('/seller/index');
} else {
$message = '用户名与密码不匹配';
}
}
}
if ($message != '') {
$this->redirect('index', false);
Util::showMessage($message);
}
}
示例2: isValidUser
/**
* @brief 校验用户的合法性
* @param string $login_info 用户名或者email
* @param string $password 用户名的md5密码
* @return false or array 如果合法则返回用户数据;不合法返回false
*/
public static function isValidUser($login_info, $password)
{
$login_info = IFilter::act($login_info);
$password = IFilter::act($password);
$userObj = new IModel('user as u,member as m');
$where = 'u.username = "' . $login_info . '" and m.status = 1 and u.id = m.user_id';
$userRow = $userObj->getObj($where);
if (empty($userRow)) {
$where = 'email = "' . $login_info . '" and m.status = 1 and u.id = m.user_id';
$userRow = $userObj->getObj($where);
}
if (empty($userRow) || $userRow['password'] != $password) {
return false;
} else {
return $userRow;
}
}
示例3: curd
/**
* @brief 处理curd动作
* @return String
*/
public function curd()
{
$action = $this->id;
$controller = $this->controller;
$curdinfo = $this->initinfo();
if (is_array($curdinfo)) {
$modelName = $curdinfo['model'];
$key = $curdinfo['key'];
$actions = $curdinfo['actions'];
switch ($action) {
case 'add':
case 'upd':
if (method_exists($controller, 'getValidate')) {
$validate = $controller->getValidate();
} else {
$validate = null;
}
if ($validate != null) {
$formValidate = new IFormValidation($validate);
$data = $formValidate->run();
}
$model = new IModel($modelName);
if (isset($data) && $data !== null) {
$model->setData($data[$modelName]);
if ($action = 'add') {
$flag = $model->add();
} else {
$flag = $model->upd("{$key} = '" . IReq::get($key) . "'");
}
}
if (isset($flag) && $flag) {
$_GET['action'] = $actions['success'];
} else {
$_GET['action'] = $actions['fail'];
}
$controller->run();
return true;
case 'del':
$model = new IModel($modelName);
$flag = $model->del("{$key} = '" . IReq::get($key) . "'");
if ($flag) {
$_GET['action'] = $actions['success'];
} else {
$_GET['action'] = $actions['fail'];
}
$controller->run();
return true;
case 'get':
$model = new IModel($modelName);
$rs = $model->getObj("{$key} = '" . IReq::get($key) . "'");
echo JSON::encode($rs);
return false;
}
}
}
示例4: IModel
function spec_edit()
{
if ($id = IFilter::act(IReq::get('id'), 'int')) {
$where = 'id = ' . $id;
$obj = new IModel('spec');
$dataRow = $obj->getObj($where);
} else {
$dataRow = array('id' => null, 'name' => null, 'type' => null, 'value' => null, 'note' => null);
}
$this->setRenderData($dataRow);
$this->redirect('spec_edit');
}
示例5: IModel
function login_act()
{
$admin_name = IFilter::act(IReq::get('admin_name'));
$password = IReq::get('password');
$captcha = IReq::get('captcha', 'post');
$message = '';
if ($admin_name == '') {
$message = '登录名不能为空';
} else {
if ($password == '') {
$message = '密码不能为空';
} else {
if ($captcha != ISafe::get('Captcha')) {
$message = '验证码输入不正确';
} else {
$adminObj = new IModel('admin');
$adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"');
if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) {
$dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime());
$adminObj->setData($dataArray);
$where = 'id = ' . $adminRow["id"];
$adminObj->update($where);
//根据角色分配权限
if ($adminRow['role_id'] == 0) {
ISafe::set('admin_right', 'administrator');
ISafe::set('admin_role_name', '超级管理员');
} else {
$roleObj = new IModel('admin_role');
$where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
$roleRow = $roleObj->getObj($where);
ISafe::set('admin_right', $roleRow['rights']);
ISafe::set('admin_role_name', $roleRow['name']);
}
ISafe::set('admin_id', $adminRow['id']);
ISafe::set('admin_name', $adminRow['admin_name']);
ISafe::set('admin_pwd', $adminRow['password']);
$this->redirect('/system/default');
} else {
$message = '用户名与密码不匹配';
}
}
}
}
if ($message != '') {
$this->admin_name = $admin_name;
$this->redirect('index', false);
Util::showMessage($message);
}
}
示例6: __construct
/**
* @brief 构造函数
* @param array checkrights里面的admin对象数据
*/
public function __construct($admin)
{
$adminObj = new IModel('admin');
$adminRow = $adminObj->getObj('admin_name = "' . $admin['admin_name'] . '"');
if ($adminRow && $adminRow['password'] == $admin['admin_pwd'] && $adminRow['is_del'] == 0) {
//根据角色分配权限
if ($adminRow['role_id'] == 0) {
$this->adminRights = 'administrator';
} else {
$roleObj = new IModel('admin_role');
$where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
$roleRow = $roleObj->getObj($where);
$this->adminRights = isset($roleRow['rights']) ? $roleRow['rights'] : '';
}
}
}
示例7: can_comment
/**
* 检测用户是否能够评论
*
* @param int $comment_id 评论id
* @param int $user_id 用户id
* @return array() array(成功or失败,数据)
*/
public static function can_comment($comment_id, $user_id)
{
$comment_id = intval($comment_id);
$user_id = intval($user_id);
$tb_comment = new IModel("comment");
$comment = $tb_comment->getObj("id={$comment_id} AND user_id={$user_id}");
if (!$comment) {
return array(-1, "没有这条数据");
}
if ($comment['status'] != 0) {
return array(-2, $comment);
}
$time = strtotime($comment['time']);
if ($time < 3600 * 24 * 30 * 6) {
return array(-3, $comment);
}
return array(1, $comment);
}
示例8: count
public static function count($word)
{
if (empty($word)) {
return false;
} else {
if (is_array($word)) {
$wordArray = $word;
} else {
$wordArray = explode(',', $word);
}
$keywordObj = new IModel('keyword');
$goodsObj = new IModel('goods');
$result = array();
foreach ($wordArray as $val) {
$val_sql = IFilter::act($val);
$countNum = $goodsObj->getObj('name like "%' . $val_sql . '%" AND is_del=0 ', 'count(*) as num');
$result[$val] = $countNum['num'];
}
return $result;
}
}
示例9: getSellerInfo
public function getSellerInfo($id)
{
$query = new IModel('seller');
$info = $query->getObj("id=" . $id);
return $info;
}
示例10: getPositionInfo
/**
* @brief 获取广告位置的信息
* @param $position mixed 广告位ID 或者 广告位名称
* @return array
*/
public static function getPositionInfo($position)
{
$adPositionDB = new IModel("ad_position");
if (is_int($position)) {
return $adPositionDB->getObj("id={$position} AND `status`=1");
} else {
return $adPositionDB->getObj("name='{$position}' AND `status`=1");
}
}
示例11: loginAfter
/**
* @brief 登录后的处理
* @param array $userRow 用户数组信息
*/
public static function loginAfter($userRow)
{
//用户私密数据
ISafe::set('user_id', $userRow['id']);
ISafe::set('username', $userRow['username']);
ISafe::set('head_ico', $userRow['head_ico']);
ISafe::set('user_pwd', $userRow['password']);
ISafe::set('last_login', isset($userRow['last_login']) ? $userRow['last_login'] : '');
//更新最后一次登录时间
$memberObj = new IModel('member');
$dataArray = array('last_login' => ITime::getDateTime());
$memberObj->setData($dataArray);
$where = 'user_id = ' . $userRow["id"];
$memberObj->update($where);
$memberRow = $memberObj->getObj($where, 'exp');
//根据经验值分会员组
$groupObj = new IModel('user_group');
$groupRow = $groupObj->getObj($memberRow['exp'] . ' between minexp and maxexp and minexp > 0 and maxexp > 0', 'id', 'discount', 'desc');
if (!empty($groupRow)) {
$dataArray = array('group_id' => $groupRow['id']);
$memberObj->setData($dataArray);
$memberObj->update('user_id = ' . $userRow["id"]);
}
}
示例12: IModel
/**
* @brief 修改品牌
*/
function brand_edit()
{
$brand_id = (int) IReq::get('bid');
//编辑品牌 读取品牌信息
if ($brand_id) {
$obj_brand = new IModel('brand');
$brand_info = $obj_brand->getObj('id=' . $brand_id);
if ($brand_info) {
$this->data['brand'] = $brand_info;
} else {
$this->category_list();
Util::showMessage("没有找到相关品牌分类!");
return;
}
}
$this->setRenderData($this->data);
$this->redirect('brand_edit', false);
}
示例13: get_model_info
/**
* @brief 根据模型编号 获取模型详细信息
*
* @param int $model_id 模型编号
*
* @return array 数组格式 Array ( [id] => '',[name] => '', [model_attr] => Array ( ),[model_spec] => Array ( ))
*/
public function get_model_info($model_id)
{
$model_id = intval($model_id);
//初始化model商品模型表类对象
$modelObj = new IModel('model');
//根据模型编号 获取商品模型详细信息
$model_info = $modelObj->getObj('id = ' . $model_id);
if ($model_info) {
//反序列化 商品模型规格数据
$model_info['model_spec'] = array();
if ($model_info['spec_ids']) {
$specDB = new IModel('spec');
$model_info['model_spec'] = $specDB->query("id in (" . $model_info['spec_ids'] . ")");
}
//初始化attribute商品模型属性表类对象
$attributeObj = new IModel('attribute');
//根据商品模型编号 获取商品模型扩展属性
$model_attr = $attributeObj->query("model_id = " . $model_id);
$model_info['model_attr'] = $model_attr;
}
return $model_info;
}
示例14: getOauthRow
private function getOauthRow($id)
{
$oauthObj = new IModel('oauth');
$oauthRow = $oauthObj->getObj('id = ' . $id);
return $oauthRow;
}
示例15: IModel
function withdraw_detail()
{
$id = IFilter::act(IReq::get('id'), 'int');
if ($id) {
$withdrawObj = new IModel('withdraw');
$where = 'id = ' . $id;
$this->withdrawRow = $withdrawObj->getObj($where);
$this->redirect('withdraw_detail', false);
} else {
$this->redirect('withdraw_list');
}
}