i've an $object coming out from a mysql_fetch_object.
SQL ok, result ok..: everything okay when print_r($obj).
next, I loop through $obj because I need to rework some fields (cut date, strings, so on)
If I comment one (RANDOMLY!!!!) line where I do a substr() the code work... commented out, the server doesn't return anything
it's a memory leak? error in my code? I'm going crazy....
this is the code snippet:
while($obj = mysql_fetch_object($result)) {
/ convert obj to array... /
$obj_array[$rowIndex] = get_object_vars($obj);
/ just print out first record only for debug /
if($rowIndex == 0) {
echo "<pre>";
var_dump($obj);
echo "</pre>";
}
/ this doesn't work too!! /
//$obj_array[$rowIndex] = (array)$obj;
/ this doesn't work too!!
$tmp = (string)$obj_array[$rowIndex][paz_Sex];
$tmp2 = substr($tmp,0,1);
$obj_array[$rowIndex][paz_Sex] = $tmp2;
/
$obj_array[$rowIndex][pr_Data_Pren] = substr($obj->pr_Data_Pren,0,10);
$obj_array[$rowIndex][pr_Ora_Pren] = substr($obj->pr_Ora_Pren,11,5);
$obj_array[$rowIndex][pr_Data_Reg] = substr($obj->pr_Data_Reg,0,10);
$obj_array[$rowIndex][paz_Com_res] = "?".$obj->paz_Com_res;
$obj_array[$rowIndex][paz_Com_nasc] = "?".$obj->paz_Com_nasc;
$obj_array[$rowIndex][pr_Prest_ICD9] = "?".$obj->pr_Prest_ICD9;
$rowIndex++;
}