Php codeigniter数据库内部联接
我的错误是您没有关联这两个数据库,信息不正确,所有查询都会出现。我只想看到相应的查询,Php codeigniter数据库内部联接,php,mysql,sql,codeigniter,inner-join,Php,Mysql,Sql,Codeigniter,Inner Join,我的错误是您没有关联这两个数据库,信息不正确,所有查询都会出现。我只想看到相应的查询,users.id=concurge.id $this->db->where('users.id',$user\u id) 错误消息:未定义变量:用户\u id 型号: class User_model extends CI_Model { public function __construct() { parent::__construct(); $this->load->data
users.id=concurge.id
$this->db->where('users.id',$user\u id)代码>
错误消息:未定义变量:用户\u id
型号:
class User_model extends CI_Model {
public function __construct() {
parent::__construct();
$this->load->database();
}
public function create_user($nome, $sobrenome, $username, $email, $password) {
$data = array(
'nome' => $nome,
'sobrenome' => $sobrenome,
'username' => $username,
'email' => $email,
'password' => $this->hash_password($password),
'created_at' => date('j-m-Y H:i:s'),
);
return $this->db->insert('users', $data);
}
public function resolve_user_login($username, $password) {
$this->db->select('password');
$this->db->from('users');
$this->db->where('username', $username);
$hash = $this->db->get()->row('password');
return $this->verify_password_hash($password, $hash);
}
public function get_user_id_from_username($username) {
$this->db->select('id');
$this->db->from('users');
$this->db->where('username', $username);
return $this->db->get()->row('id');
}
public function get_user($user_id) {
$this->db->from('users');
$this->db->where('id', $user_id);
return $this->db->get()->row();
}
private function hash_password($password) {
return password_hash($password, PASSWORD_BCRYPT);
}
private function verify_password_hash($password, $hash) {
return password_verify($password, $hash);
}
public function get_conjuge(){
$this->db->select('conjuge.id, conjuge.nome, conjuge.sobrenome, conjuge.cpf, conjuge.rg');
$this->db->from('conjuge');
$this->db->join('users', 'users.id = conjuge.id', 'inner');
$this->db->where('users.id', $user_id);
$query = $this->db->get();
return $query->result();
}
我没有解决
public function get_conjuge($user_id){
$this->db->select('conjuge.id, conjuge.nome, conjuge.sobrenome, conjuge.cpf, conjuge.rg', 'users.id AS users');
$this->db->from('conjuge');
$this->db->join('users', 'users.id = conjuge.id', 'inner');
$this->db->where('users.id', $user_id);
$query = $this->db->get();
return $query->result();
}
遇到一个PHP错误
严重性:警告
消息:中调用的用户\模型::get\ u Concurge()缺少参数1
/home/planoser/public_html/oauth/application/controllers/User.php on
第160行并定义
文件名:models/User_model.php
遇到一个PHP错误
严重性:通知
消息:未定义变量:用户\u id
文件名:models/User_model.php
需要在查询中添加选择用户、用户id、
$this->db->select('conjuge.id, conjuge.nome, conjuge.sobrenome, conjuge.cpf, conjuge.rg','users.user_id');
public function get_conjuge() {
}
然后将函数更改为带参数
public function get_conjuge($user_id) {
}
您没有将$user\u id
传递给您的函数可能重复您需要将$userid
传递给get\u concurge()
函数,如get\u concurge($userid)