Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在codeigniter中编写sql查询_Php_Codeigniter - Fatal编程技术网

Php 如何在codeigniter中编写sql查询

Php 如何在codeigniter中编写sql查询,php,codeigniter,Php,Codeigniter,如何在codeigniter中编写此代码? 我想在php codeigniter中转换此代码 $query="SELECT * FROM class,student WHERE class.class_name= '$name' AND student.class_id='$name'"; 尝试使用活动记录 $this->db->select('*'); $this->db->from('class'); $this->db->join('stude

如何在codeigniter中编写此代码? 我想在php codeigniter中转换此代码

$query="SELECT * FROM class,student 
   WHERE class.class_name= '$name' AND student.class_id='$name'";

尝试使用活动记录

$this->db->select('*');
$this->db->from('class');
$this->db->join('student', 'student.id = class.student_id'); // check the join i.e the common column
$this->db->where('class_name', $name);
$this->db->where('class_id', $name);
请尝试此查询

    $this->db->where('class_name',$name);
    $this->db->select('*');
    $this->db->from('class');
    $this->db->join('student', 'student.class_id = class.class_name');
    $query = $this->db->get();
    return $query->result();

欢迎来到SO。请先到,然后阅读并提供答案。如果周围的人能够很容易地阅读和理解你的意思,或者问题是什么,他们会更愿意提供帮助:)我建议看一下Codeigniter手册。这就是为什么人们要花时间写它的原因。在查询生成器类中的Codeigniter 3.1手册中,声明了一些变量,并将值传递给该变量。但是我声明了一个变量,并在这个变量中存储了一个输入数组。如何在多个位置使用此变量??消息:未定义变量:名称文件名:views/vstudent.php行号:17您必须将变量($name)从控制器传递到模型