i'm having trouble with rest API result in Codeigniter 2.2.6
i want to select 2 (full_name, username) column in table participant, but in result full_name column is missing
here is screenshot when i try to SELECT in POSTMAN
here my script for select
Code:
function select_post(){
if(!$this->post('table')){
$this->response('no table'); return 0;
}
if($this->post('table')=='user'){
$pos1=false;
$pos2=false;
if($this->post('where') ){
$pos1 = stripos($this->post('where'),'password');
}
if($this->post('select')){
$pos2 = stripos($this->post('select'),'password');
}
if($pos1 !== false || $pos2 !== false){
$this->response('select password is prohibited');return 0;
}
}
if($this->post('join')&&$this->post('on'))
$this->db->join($this->post('join'),$this->post('on'));
if($this->post('table')=='user'){
if($this->post('where')) {
$this->db->where($this->post('where').'AND role = 1');
} else {
$this->db->where('role = 1');
}
} else {
if($this->post('where')) $this->db->where($this->post('where'));
}
if($this->post('select'))
$this->db->select($this->post('select'));
if($this->post('limit')){
$this->db->limit($this->post('limit'));
}else{
$this->db->limit(10);
}
if($this->post('limit')&&$this->post('offset'))
$this->db->limit($this->post('limit'),$this->post('offset'));
if($this->post('order'))
$this->db->order_by($this->post('order'));
$query = $this->db->get($this->post('table'));
$result=$query->result();
$txtOut="[";
foreach($result as $row){
$txtOut.="{";
$row=(array)$row;
foreach($row as $col){
if(key($row)!=='password'&&key($row)!=='key'){
$txtOut.='"'.key($row).'"="'.$col.'",';
}
next($row);
}
$txtOut=rtrim($txtOut,",");
$txtOut.="},";
}
$txtOut=rtrim($txtOut, ",");
$this->logging('select',json_encode($_POST),$txtOut."]");
echo $txtOut."]";
}
Any ideas where i do wrong ?