本文整理汇总了PHP中think\Model::field方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::field方法的具体用法?PHP Model::field怎么用?PHP Model::field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类think\Model
的用法示例。
在下文中一共展示了Model::field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doLogin
public function doLogin()
{
// 参数非法,则重新登录
if (empty($_POST["name"]) || empty($_POST["password"]) || empty($_POST["code"])) {
$this->ajaxReturn(array("content" => null, "info" => "输入不能为空", "status" => false));
exit(1);
}
//验证码生成
$code = $_POST['code'];
$Ver = new CodeController();
if (!$Ver->check_verify($code)) {
// 验证码错误
$this->ajaxReturn(array("content" => null, "info" => "验证码错误", "status" => false));
$this->error("验证码错误", "index");
exit(1);
}
//获取用户名
$username = $_POST['name'];
//获取密码
$password = $_POST["password"];
//创建systemmanager 的Model
$m = new Model("systemmanager");
//$res = $m->field ( "sys_password,sys_id" )->where ( "sys_username='{$username}'" )->select ();
$res = $m->field("sys_password,sys_id")->where("sys_username='%s'", $username)->select();
// 防注入 查找
if ($res[0]['sys_password'] == md5($password)) {
//若账号和密码都正确则登录成功,并存入相关session
$_SESSION['systemmanager'] = $username;
$_SESSION['sys_id'] = $res[0]['sys_id'];
$this->ajaxReturn(array("content" => null, "info" => "登录成功!", "status" => true));
}
//用户名或者密码错误,则登录失败
$this->ajaxReturn(array("content" => null, "info" => "用户名或者密码错误!", "status" => false));
}
示例2: 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));
}