[eluser]taviroquai[/eluser]
Hi all,
I'm new to CI and I'm getting RECURSIVE echo from var_dump... but i'm sure that I don't have any recursivity in my code.
I'm not sure if I can post my code here, but I can explain how is my code:
Models:
units (loads "unit" model)
unit (loads "unitmodel" model)
unitmodel (loads "unittype", "unitfeatures" and "requirement" models)
unittype
unitfeatures
requirement
Controller:
cunit (loads "units" model)
passes units data to "units_view" view
View:
units_vuew (echos vars from object units)
When I var_dump the object units, it shows the following:
object(Units)#30 (27) {
[“dbtable”]=> string(12) “players_unit”
[“data”]=> array(1) {
[0]=> object(Unit)#32 (28) {
[“dbtable”]=> string(12) “players_unit”
[“data”]=> object(stdClass)#40 (5) {
[“id”]=> string(1) “4”
[“amount”]=> string(1) “1”
[“geometry”]=> string(25) “��������Xd�I�h�T��P@”
[“players_id”]=> string(1) “5”
[“units_model_id”]=> string(2) “23”
}
[“modelo”]=> object(UnitModel)#33 (30) {
[“dbtable”]=> string(11) “units_model”
[“data”]=> object(stdClass)#42 (11) {
[“id”]=> string(2) “23”
[“name”]=> string(6) “Apache”
[“icon”]=> string(17) “heli_castanho.png”
[“scale”]=> string(1) “1”
[“hotspot”]=> string(7) “0.4,0.7”
[“labelcolor”]=> string(8) “ffffffff”
[“labelscale”]=> string(1) “0”
[“labelcolormode”]=> string(6) “normal”
[“units_type_id”]=> string(1) “9”
[“unit_level”]=> string(1) “2”
[“requirements_id”]=> string(1) “0”
}
[“type”]=> object(UnitType)#34 (27) {
[“dbtable”]=> string(10) “units_type”
[“data”]=> object(stdClass)#44 (5) {
[“id”]=> string(1) “9”
[“name”]=> string(10) “helicopter”
[“max_level”]=> string(1) “3”
[“ocean”]=> string(1) “1”
[“earth”]=> string(1) “1”
}
[“_parent_name”]=> string(8) “UnitType”
[“list”]=> &object;(Units)#30 (27) {
[“dbtable”]=> string(12) “players_unit”
[“data”]=> array(1) {
[0]=> object(Unit)#32 (28) {.......... RECURSION
As you can see... at some point... it says that i have recursion having objects inside objects... the "list" object inside the "type" object... but i can't see this recursion in my code!
Here is my class UnitType:
Code:
<?php
/**
* Description of UnitType
*
* @author mafonso
*/
class UnitType extends Model {
/*
* Vars
*/
var $dbtable = 'units_type';
var $data;
function UnitType() {
parent::Model();
}
/*
* return data
*/
function get($name) {
return $this->data->$name;
}
/*
* load directly from db
*/
function loadFromDb($id) {
/*
* Build query to get data
*/
$query = $this->db->get_where($this->dbtable, array('id' => $id));
/*
* Check if record exists
*/
if ($query->num_rows() == 0) return false;
/*
* load data into vars
*/
$this->data = $query->row();
return true;
}
}
?>
If i don't do var_dump, the code runs ok and it don't crashes...
What would be?
Thanks!