Error fatal: No se puede usar el objeto de tipo stdClass como matriz en
Estoy recibiendo el error:
"Error fatal: No se puede usar el objeto de tipo stdClass como matriz en" en la línea 183
De este código:
$getvidids = $ci->db->query(
"SELECT * FROM videogroupids " .
"WHERE videogroupid='$videogroup' AND used='0' LIMIT 10");
foreach ($getvidids->result() as $row){
$vidid = $row['videoid']; //This is line 183
}
¿Alguien sabe lo que está mal con el código anterior? ¿O qué significa este error?
25
Author: Eric Leschinski, 2011-03-24
3 answers
CodeIgniter devuelve las filas de resultados como objetos, no como matrices. De la guía del usuario :
Resultado ()
Esta función devuelve el resultado de la consulta como una matriz de objetos, o una matriz vacía en caso de fallo.
Tendrás que acceder a los campos usando la siguiente notación:
foreach ($getvidids->result() as $row) {
$vidid = $row->videoid;
}
62
Author: BoltClock,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-23 23:26:06
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-23 23:26:06
Si realmente quieres un array en su lugar puedes usar:
$getvidids->result_array()
Que devolvería la misma información que un array asociativo.
15
Author: icchanobot,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-24 01:56:50
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-24 01:56:50
Lo siento.Aunque es un poco tarde, pero espero que ayude a otros también . Utilice siempre el objeto stdClass.por ejemplo,
$getvidids = $ci->db->query("SELECT * FROM videogroupids WHERE videogroupid='$videogroup' AND used='0' LIMIT 10");
foreach($getvidids->result() as $key=>$myids)
{
$vidid[$key] = $myids->videoid; // better methodology to retrieve and store multiple records in arrays in loop
}
-3
Author: Bilal Khalid,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-19 14:14:47
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-19 14:14:47