The following is also fine:
if($query1->num_rows() > 0){
$row = $query1->row();
}
return $row->dPassword;
Then if your query was to return more than a single row you could operate on the results like so:
foreach($query1->result() as $row){
echo $row->field1;
echo $row->field2;
echo $row->etcetera;
}
For single row results i usually return the row directly from the model like so:
return $query1->row();
Here is an example of this:
function select_provider_details($provider_id)
{
$this->db->select('*');
$this->db->from('providers');
$this->db->where('provider_id', $provider_id);
$query = $this->db->get();
if($query->num_rows() > 0)
{
$result['success'] = TRUE;
$result['query'] = $query->row();
}
else
{
$result['success'] = FALSE;
$result['error'] = "Provider not found in database";
$result['errorcode'] = "E003";
$result['query'] = $query->row();
}
return $result;
}
Or for a query expected to return multiple results i return the entire results object:
return $query1;