本文整理汇总了PHP中think\Model::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::table方法的具体用法?PHP Model::table怎么用?PHP Model::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类think\Model
的用法示例。
在下文中一共展示了Model::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: regist
/**
* 注册
* @param array $data 注册数据
*/
public function regist($data)
{
// 将用户信息添加到User表中
$tranDb = new Model();
$tranDb->startTrans();
$username = $data['username'];
$result = $tranDb->table('world_user')->where("username = '{$username}'")->find();
if ($result == null) {
$user_info = array('username' => $username, 'password' => $data['password'], 'session' => md5(time() . $username), 'modify_time' => time(), 'last_time' => time());
$uid = $tranDb->table('world_user')->data($user_info)->add();
$tranDb->commit();
return 1;
// 注册用户成功
} else {
return -1;
// 用户名已存在
}
}
示例2: checkQq
/**
* 检查该QQ是否已被注册
* @param string qq 用户提交的qq字段
* @access protected
* */
protected function checkQq($qq)
{
$mo = new Model();
$mo->table('__USERS__');
if (empty($mo->where(array('qq' => $qq))->find())) {
return true;
} else {
return false;
}
}
示例3: regist
/**
* 注册
* @param array $data 注册数据
*/
public function regist($data)
{
// 将用户信息添加到User表中
$tranDb = new Model();
$tranDb->startTrans();
$username = $data['username'];
$result = $tranDb->table('west_user')->where("username = '{$username}'")->find();
if ($result == null) {
$user_info = array('username' => $username, 'password' => $data['password'], 'group' => 'user', 'status' => 0, 'modify_time' => time());
$uid = $tranDb->table('west_user')->data($user_info)->add();
if ($uid) {
// 判断公司是否存在
$company_name = $data['company_name'];
$result = $tranDb->table('west_company')->where("name = '{$company_name}'")->find();
if ($result == null) {
$company_info = array('uid' => $user_id, 'name' => $data['company_name'], 'mail' => $data['company_mail'], 'tel' => $data['company_tel'], 'modify_time' => time());
$result = $tranDb->table('west_company')->data($company_info)->add();
if ($result) {
$tranDb->commit();
return 1;
// 注册用户成功
} else {
$tranDb->rollback();
return -4;
// 添加公司信息失败
}
} else {
$tranDb->rollback();
return -3;
// 公司名称已存在
}
} else {
$tranDb->rollback();
return -2;
// 添加用户信息失败
}
} else {
return -1;
// 用户名已存在
}
}
示例4: touchCheck
public function touchCheck()
{
$pub = Utility::sslTrimKey($this->platform['public_key']);
$ret = "<biz_content>{$pub}</biz_content><success>true</success>";
$dat = $this->client->encryptAndSign($ret, false, true);
parent::touchCheck();
$message = $this->parse($this->params['biz_content']);
$rec = array();
$rec['appid'] = $message['to'];
$m = new Model();
$m->table('__PLATFORM_ALIPAY__')->data($rec)->where("`id`='{$this->platform['id']}'")->save();
exit($dat);
}
示例5: getNews
function getNews($page, $page_size)
{
/*return $this->join('term_relationships ON post.ID = term_relationships.object_id ')
->where(array('post_type' => 'post','post_status'=>'publish')
->page($page, $page_size)
->order('post_date DESC')
->select(); */
$Model = new Model();
return $Model->table('wp_posts')->join('wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id')->where(array('wp_posts.post_type' => 'post', 'wp_posts.post_status' => 'publish'))->where("wp_term_relationships.term_taxonomy_id = 1")->page($page, $page_size)->order('post_date DESC')->select();
/* $Model = new Model();
return $Model->query("SELECT * from wp_posts wp where wp.post_type = 'post'
and wp.post_status = 'publish'
join wp_term_relationships wtr where wp.ID = wtr.object_id and wtr.term_taxonomy_id = 1 ")->page($page, $page_size)
->order('post_date DESC') ; */
}
示例6: saveSettings
/**
* 将配置项写入数据库, 一般预留给模块封装调用, 控制其中不应该直接调用
* @param $moduleName string 模块名称
* @param $settings array 配置项名称
* @return bool
*/
public static function saveSettings($moduleName, $settings)
{
$moduleName = strtoupper($moduleName);
$ds = array();
foreach ($settings as $key => $value) {
if (!empty($key)) {
$key = strtoupper($key);
$origKey = "{$moduleName}:{$key}";
$ds[$origKey] = serialize($value);
}
}
if (empty($ds)) {
return false;
}
$m = new Model();
foreach ($ds as $key => $value) {
$rec = array();
$rec['key'] = $key;
$rec['value'] = $value;
$m->table('__CORE_SETTINGS__')->add($rec, array(), true);
}
return true;
}
示例7: getAddon
public static function getAddon($name, $fromDefineFile = false)
{
if ($fromDefineFile) {
$path = MB_ROOT . "addons/{$name}/define.xml";
if (is_file($path)) {
$xml = file_get_contents($path);
$addon = self::parseDefineFile($xml);
if (is_error($addon)) {
return $addon;
}
} else {
return error(-1, '不存在这个扩展或者扩展定义文件不存在');
}
} else {
$condition = '`name`=:name';
$pars = array();
$pars[':name'] = $name;
$m = new Model();
$addon = $m->table('__EX_ADDONS__')->where($condition)->bind($pars)->find();
if (empty($addon)) {
return error(-1, '不存在这个扩展');
}
}
if (!empty($addon)) {
$addon['icon'] = __SITE__ . "addons/{$addon['name']}/icon.png";
}
return $addon;
}
示例8: changeOrderStatus
/**
* 支付成功,改变订单状态
* @param int $order_id
* @return bool
*/
public function changeOrderStatus($order_id)
{
$flag = false;
if ($order_id) {
$db = new Model();
$flag = $db->table($this->_table)->where(['id' => $order_id])->save(['status' => 2]);
}
return $flag;
}
示例9: test_db
/**
* 检测数据库连接,成功则输出成功信息,失败则报错
* @access public
* */
public function test_db()
{
$mo = new Model();
$msg = $mo->table('wa_users')->getDbFields();
echo '连接成功!';
}
示例10: uninstallAction
public function uninstallAction()
{
$a = I('get.addon');
if (empty($a)) {
$this->error('访问错误');
}
$addon = new Addon($a);
Addon::autoload();
$class = "Addon\\{$a}\\Api\\Application";
if (class_exists($class)) {
$instance = new $class();
if (!empty($instance)) {
$instance->addon = $addon;
if (method_exists($instance, 'install')) {
$instance->uninstall();
}
}
}
$condition = '`name`=:name';
$pars = array();
$pars[':name'] = $a;
$m = new Model();
$m->table('__EX_ADDONS__')->where($condition)->bind($pars)->delete();
$m->table('__EX_ADDON_ENTRIES__')->where('`addon`=:name')->bind($pars)->delete();
$m->table('__RP_PROCESSORS__')->where('`from`=:name')->bind($pars)->delete();
$m->table('__RP_REPLIES__')->where('`from`=:name')->bind($pars)->delete();
$this->success('扩展卸载成功');
}
示例11: get_order
/**
* 订单详情
*/
public function get_order()
{
$order_no = isset($_POST['order_no']) ? htmlspecialchars($_POST['order_no']) : '';
$mer_session_id = $_POST['mer_session_id'];
$merchant_id = $this->session_handle->getsession_userid($mer_session_id);
if (empty($order_no)) {
$this->jsonUtils->echo_json_msg(4, '订单ID为空...');
exit;
}
$model = new Model();
$arr = $model->table(C('DB_PREFIX') . "order as a ")->field("b.header,b.nick_name,a.member_id,a.service_name,a.id,a.order_no,a.addtime,b.mobile,a.cart_id,a.cart_data,a.reach_time,a.total_price,a.total_time,a.type,a.sub_id,a.sub_data,a.status,a.merchant_comment,a.member_comment,a.merchant_remark,a.member_remark,ifnull(a.fail_content,'') as fail_content,b.mobile")->join(C('DB_PREFIX') . "member as b on a.member_id = b.id")->where("a.order_no = {$order_no} and a.merchant_id = {$merchant_id} and a.merchant_del = 0")->find();
//echo $model->getLastSql();
if ($arr) {
//获取jid
$jid = CommonController::getSystemUserid($arr['member_id'], 0);
$cart = json_decode($arr['cart_data'], true);
unset($arr['cart_data']);
$arr['system_user_id'] = $jid;
$arr['cart_model'] = $cart['cart_model'];
$arr['reach_time'] = date('Y-m-d H:i:s', $arr['reach_time']);
$arr['addtime'] = date('Y-m-d H:i:s', $arr['addtime']);
$arr['header'] = imgUrl($arr['header']);
// 商家是否评价
if ($arr['status'] != 0) {
// 未完成订单 没有评价
if ($arr['merchant_comment'] > 0) {
$sql = "select a.desc,c.header,a.service_attitude,c.merchant_name as nick_name,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime\r\n\t \t\tfrom " . C('DB_PREFIX') . "comment as a\r\n\t \t\tleft join " . C('DB_PREFIX') . "merchant as c\r\n\t \t\ton a.merchant_id=c.id\r\n\t \t\twhere a.order_no={$arr['order_no']} and type=2 limit 1";
$arro = $this->dao->query($sql);
$arro[0]['header'] = imgUrl($arro[0]['header']);
$arr['merchant_comment_info'] = $arro[0];
} else {
$arr['merchant_comment_info'] = '';
$arr['merchant_comment'] = '0';
}
// 用户是否评论
if ($arr['member_comment'] > 0) {
$sql = "select a.desc,c.header,c.nick_name,a.service_attitude,a.service_quality,a.merchant_setting,a.pics,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime\r\n\t\t \tfrom " . C('DB_PREFIX') . "comment as a \r\n\t\t \tleft join " . C('DB_PREFIX') . "member as c \r\n\t\t \ton a.member_id=c.id \r\n\t\t \twhere a.order_no={$arr['order_no']} and type=0 limit 1";
$arro = $this->dao->query($sql);
$arro[0]['header'] = imgUrl($arro[0]['header']);
$arro[0]['pics'] = imgUrl(json_decode($arro[0]['pics'], true));
$arr['member_comment_info'] = $arro[0];
} else {
$arr['member_comment_info'] = '';
$arr['member_comment'] = '0';
}
} else {
$arr['merchant_comment'] = '0';
$arr['member_comment'] = '0';
$arr['merchant_comment_info'] = '';
$arr['member_comment_info'] = '';
}
$sub_data = json_decode($arr['sub_data'], true);
switch ($arr['type']) {
// 0 预约 1需求 2活动
case '0':
$arr['pics'] = imgUrl($sub_data['pics']);
$arr['distance'] = '';
$arr['list'] = $sub_data['list'];
break;
case '1' or '3':
// 需求
$arr['pics'] = imgUrl($sub_data['pics']);
$arr['distance'] = $sub_data['distance'];
$arr['list'] = $sub_data['list'];
break;
case '2':
// 活动
$arr['distance'] = '';
$arr['list'] = array();
break;
default:
$this->jsonUtils->echo_json_msg(4, '数据异常');
exit;
break;
}
unset($arr['sub_data']);
$this->jsonUtils->echo_json_data(0, 'ok', $arr);
} else {
$this->jsonUtils->echo_json_msg(1, '该订单不存在...');
exit;
}
}
示例12: EditSave
/**
*修改用户
*/
public function EditSave()
{
//获取参数
$id = I('id', 0, 'int');
$username = I('username');
$password = I('password');
$email = I('email');
$mobile = I('mobile');
$roleid = I('role_id');
//是否修改
if ($id == 0) {
$result['result'] = false;
$result['msg'] = '该用户不存在';
$this->ajaxReturn($result);
}
//开启事务
$model = new Model();
$model->startTrans();
$flage === false;
//申明修改用户对象
$data['UserName'] = $username;
if (!empty($password)) {
$data['PassWord'] = md5($password);
}
$data['Email'] = $email;
$data['Mobile'] = $mobile;
//更新
$flage = $model->table('sys_user')->where('id=%d', $id)->save($data);
if ($flage === false) {
//事务回滚
$model->rollback();
$result['result'] = false;
$result['msg'] = '修改用户资料失败!';
$this->ajaxReturn($result);
} else {
$flage = $model->table('sys_role_user')->where('user_id=%d', $id)->delete();
if ($flage === false) {
//事务回滚
$model->rollback();
$result['result'] = false;
$result['msg'] = '修改用户资料失败!';
$this->ajaxReturn($result);
}
//角色处理
foreach ($roleid as $key => $value) {
# code...
$data2['role_id'] = $value;
$data2['user_id'] = $id;
$flage = $model->table('sys_role_user')->add($data2);
if ($flage === false) {
//事务回滚
$model->rollback();
$result['result'] = false;
$result['msg'] = '修改用户资料失败!';
$this->ajaxReturn($result);
}
}
if ($flage) {
//事务提交
$model->commit();
$result['result'] = true;
$result['msg'] = '修改用户资料成功!';
$this->ajaxReturn($result);
}
}
}
示例13: testUnion
public function testUnion()
{
$config = $this->getConfig();
$user_model = new Model('user', $config);
$union = "SELECT consignee FROM __USER_ADDRESS__";
$result = $user_model->field('username')->union($union)->select();
$this->assertEquals(4, count($result));
$model = new Model('', $config);
$union = ["SELECT create_time FROM __ORDER__"];
$result = $model->table([$config['prefix'] . 'user'])->field('create_time')->union($union, true)->select();
$this->assertEquals(4, count($result));
}
示例14: getMerchantBiddingBy
/**
* 获取商家对某个需求的各个项目报价
*/
public function getMerchantBiddingBy($demand_id, $merchant_id, $publish)
{
$prefix = C('DB_PREFIX');
if ($publish == 0) {
$dbname = 'category';
} elseif ($publish == 1) {
$dbname = 'car_maintain_category';
} else {
$this->jsonUtils->echo_json_msg(4, 'publish方式出错');
exit;
}
$db = new Model();
$data = $db->table($prefix . "member_demand_subitems as a")->field('b.name,b.id')->join($prefix . $dbname . ' as b on a.category_id = b.id')->where("a.demand_id = {$demand_id}")->select();
$rel = M("MerchantBidding ")->field('sub_id as id,price,out_time as time')->where("demand_id = {$demand_id} and merchant_id\r\n \t\t\t= {$merchant_id}")->select();
foreach ($rel as $key => $row) {
$price[$row['id']] = $row;
}
foreach ($data as $l => $r) {
$data[$l]['price'] = !isset($price[$r['id']]['price']) ? '-1' : $price[$r['id']]['price'];
$data[$l]['time'] = !isset($price[$r['id']]['time']) ? '-1' : $price[$r['id']]['time'];
}
return $data;
}
示例15: Del_Form_Data
/**
* 删除数据
* @param string $datalist 数据集合
*/
public function Del_Form_Data($vid, $mid)
{
$db_form = new DbformModel();
$tables = $db_form->GetDBFormVid($vid);
$Model = new Model();
$tmd = $Model->table($tables['form_table']);
$result = $tmd->where('id=' . $mid)->delete();
return $result;
}