CodeIgniter Forums
Unexpected result from DB query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Unexpected result from DB query (/showthread.php?tid=18475)



Unexpected result from DB query - El Forum - 05-07-2009

[eluser]philstan[/eluser]
To determine the location of some images, I am running this code:

$retval = array();
$retval2 = array();
$logos = array();

//Search for np companies
$this->load->model('Company_info');

//Search for the company data
$retval = $this->Company_info->get_np_partnerships($company_id);

//Count the rows returned
$how_many = count($retval);

$i= 0;


//Create an array with just the Np Company IDs
while ($i < $how_many)
{
$logos[$i] = $retval[$i]['np_id'];

$i++;
}

//Create a comma delimited list from the array for the SQL
$logo_list = implode(",",$logos);


//Run the SQL and return a list of Co logos
$sql = "SELECT logo_url FROM fh_np_companies WHERE np_id IN ($logo_list)";

$retval2 = $this->db->query($sql);

print_r ($retval2);



However instead of returning a list of company logos, it is returning this unexpected result:



CI_DB_mysql_result Object ( [conn_id] => Resource id #28 [result_id] => Resource id #36 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 2 [row_data] => )


I know that the sql works because when I plug it into phpMyAdmin it does return the correct data. Anyone know what's going on?

Thank you, Philstan