php - Codeigniter 选择在哪里 AND
问题描述
如何选择 where 和 with code igniter ?
//select * from item_user where email="myemail@gmail.com" and passwd="123"
function index_get() {
$email = $this->get('email');
$passwd = $this->get('passwd');
$sql = "SELECT * FROM web_user ";
if ($email != '') {
$this->db->where('email', $email & 'passwd', $passwd);
$item_user = $this->db->get('web_user')->result();
}
if ($item_user) {
$this->response([
'status' => true,
'message' => 'found',
'data' => $item_user
], REST_Controller::HTTP_OK);
} else {
$this->response([
'status' => false,
'message' => 'not found',
], REST_Controller::HTTP_NOT_FOUND);
}
}
我认为我的语法错误,$this->db->where('email', $email & 'passwd', $passwd);
请帮助我,在哪里可以轻松学习这种 CI 内容?
解决方案
希望这可以帮助
$this->db->where('email', $email);
$this->db->where('passwd', $passwd);
$item_user = $this->db->get('web_user')->result();
如果您正在使用GET方法使用此方法获取数据
$email = $this->input->get('email');
如果您使用POST方法使用此方法获取数据
$email = $this->input->post('email');
推荐阅读
- php - 使用 Laravel Passport 和 Tenancy for Laravel 的问题
- java - 一旦我修改 Java 代码,应用程序就会在 android studio 模拟器中崩溃
- c# - 如何在我的数据库中进行全文搜索
- python - 在 Python 中保存 CSV 时提供动态文件名
- java - 在使用 java 和 selenium 执行期间获得以下类型的异常
- apache-flink - 在类路径中找不到适合“org.apache.flink.table.factories.TableSourceFactory”的表工厂
- mongodb - MongoDB - 查找 - 多个集合 - 结果在一个数组中
- php - 如何使用 PHPWord 更改模板 Word 文件中的属性标题
- abp - ABP.IO CURD 生成器中的 DateTimeOffset 支持
- python-3.x - ValueError:int() 的无效文字,以 10 为底:“系统区域”