$this->load->library('ssp');
$table = 'ip_users`,`ip_projects`,`ip_proj_additional_info';
$primaryKey = 'id';
$host = $this->db->hostname;
$username_host = $this->db->username;
$pass_host = $this->db->password;
$db = $this->db->database;
$sql_details = array(
'user' => $username_host,
'pass' => $pass_host,
'db' => $db,
'host' => $host
);
$columns = array(
array( 'db' => 'fname', 'dt' => 0 ),
array( 'db' => 'lname', 'dt' => 1 ),
array( 'db' => 'title', 'dt' => 2 ),
array( 'db' => 'refund_status', 'dt' => 3 ),
array( 'db' => 'role', 'dt' => 4 ),
array( 'db' => 'id', 'dt' => 5 ),
array( 'db' => 'status', 'dt' => 6 ),
);
leftJoin( 'ip_proj_additional_info', 'ip_proj_additional_info.user_id', '=', 'ip_users.id' );
leftJoin( 'ip_projects', 'ip_projects.project_id', '=', 'ip_proj_additional_info.pid' );
if($type != ""){
//waiting for refund
if($type == "waiting_refund"){
$where = "ip_proj_additional_info.refund_status ='1'";
}
//refunded uses
if($type == "refunded"){
$where = "ip_proj_additional_info.refund_status = '2'";
}
}else{
$where = "";
}
$whereResult="";
$output_array=SSP::complex( $_GET, $sql_details, $table,$primaryKey, $columns,$where,$whereResult);
$result = $output_array['data'];
答案 0 :(得分:2)
它会帮助你。
$this->db->select ( 'field_name' );
$this->db->from ( 'table1 T1' );
$this->db->join ( 'table2 T2', 'T1.id = T2.id', 'LEFT' );
$this->db->where ( 'T1.id', $id );
$query = $this->db->get ();