I have successfully made a soap server using codeigniter. i want pass an array from model to controller. but i only get null. here my code:
Model:
$this->db->select('player_item, count(*) as total');
$this->db->from('rps');
$this->db->group_by('player_item');
$query = $this->db->get();
$rows = array();
foreach ($query->result_array() as $row)
{
$rows[] = $row;
}
return $rows;
Soap server:
function get_player(){
$CI =& get_instance();
$CI->load->model("player");
$data['player']=$CI->player ->get_player();
return $data;
}
Soap client:
$result = $this->nusoap_client ->call('get_player');
print_r($result);
i don't know my code at server correct or not. i am just new to SOAP..
try to write below of this line
$data['player']=$CI->player ->get_player();
echo '<pre>';
print_r($data);
echo '</pre>';
die;
and check weather you are getting data or not .if you are not getting data then var_dump($this->db->last_query());
and you can also check in model that you are getting data from database or not.
$this->db->select('player_item, count(*) as total');
$this->db->from('rps');
$this->db->group_by('player_item');
$query = $this->db->get();
$rows = array();
foreach ($query->result_array() as $row)
{
$rows[] = $row;
}
echo '<pre>';
print_r($rows);
echo '</pre>';
die;
return $rows;
Add second parameter in select('fields', false)
function false
to skip automatic apostrophe on fields, CI automatic add apostrophe on mysql query fields, so when you use mysql function like count(*)
then it will give you mysql error, your query will look like
SELECT `player_item`, `count(*)` as `total` ......
changes
$this->db->select('player_item, count(*) as total');
to
$this->db->select('`player_item`, count(*) as `total`', false);