Welcome Guest, Not a member yet? Register   Sign In
A newbie on php and CI
#11

[eluser]sandwormusmc[/eluser]
When you did the print_r of $result, you were printing out a reference to the resulting data set of your SQL statement. This is how PHP keeps track of the data it pulled as a result of your query. Hence the "mysql_result" part of the CI_DB_mysql_result object.

What you could have done from there is something like:

Code:
while($row=mysql_fetch_row($result)){
  print_r($result);
}

This would have printed out all of the resulting rows from the original query. CI does this for you with the functions "result()", "result_array()", and "result_object()".

Also, another observation ... you could have used double quotes in your first SQL call. Instead of
Code:
$this->db->query(’Select nam_first_name from NAM where nam_id = “.$var1.“‘);
, you could have used something like
Code:
$this->db->query("SELECT nam_first_name FROM NAM WHERE nam_id = $var1;");

Single quotes: doesn't parse the variables in the string; Double quotes: will automatically expand the variables.

Not sure on the performance impact, but it makes the code a bit readable. Big Grin


Messages In This Thread
A newbie on php and CI - by El Forum - 02-11-2008, 03:00 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:20 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:22 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:29 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:30 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:37 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:47 PM
A newbie on php and CI - by El Forum - 02-11-2008, 03:56 PM
A newbie on php and CI - by El Forum - 02-11-2008, 08:12 PM
A newbie on php and CI - by El Forum - 02-12-2008, 02:26 PM
A newbie on php and CI - by El Forum - 02-12-2008, 04:27 PM
A newbie on php and CI - by El Forum - 02-12-2008, 04:39 PM
A newbie on php and CI - by El Forum - 02-13-2008, 01:11 PM
A newbie on php and CI - by El Forum - 02-13-2008, 01:15 PM
A newbie on php and CI - by El Forum - 02-13-2008, 01:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB