[eluser]NateL[/eluser]
my controller - called client, is passed a string of text and assigned to the variable $client:
Code:
function index($client)
{
$data['client'] = $this->clients_model->get_this_client($client);
var_dump($data);
$this->load->view('client', $data);
}
It loads the clients_model method called get_this_client.
get_this_client simply queries the database and returns the result.
But, my var_dump spits out this info:
Code:
array
'client' =>
array
0 =>
object(stdClass)[14]
public 'id' => string '1' (length=1)
public 'userid' => string '3' (length=1)
public 'clientname' => string 'Test Client' (length=11)
public 'clientdir' => string 'testclient' (length=10)
Now - in my view - client - I am passing it the variable $data. I SHOULD be able to just plug in this code:
Code:
<?=$clientname?> // echos 'Test Client'
but - I have to use this code:
Code:
<?=$data[0]->clientname?> // echos 'Test Client'
which isn't right... Why am I getting that extra array in there?
If it helps any, here is
Clients_model.php
Code:
function get_this_client($client)
{
$this->db->select('*')->
from('clients')->
where('clientdir', $client);
$cdata = $this->db->get();
if ($cdata->num_rows() > 0){
return $cdata->result();
}
}