query result into array |
[eluser]FabricioFirmino[/eluser]
Hi! I've searched in this forum if there is a way to query result to be a array of arrays (not a array of objects) although i can't find a function like it. Who know if is there this resource in datamapper? thanks!
[eluser]Jamie Rumbelow[/eluser]
Hi Fabrico, Could you be more specific? Do you want this functionality in CodeIgniter itself, or the DataMapper Library? Jamie
[eluser]Kenshiro[/eluser]
instead of using $query->result(), use $query->result_array() instead ![]()
[eluser]FabricioFirmino[/eluser]
OK, i'll try. I'm using datamapper to model. To view i'm using template engine, like the example bellow. Code: <html> But datamapper return for me an array of objects person. In template i can't do {person->name} and {person->age} is there a way to datamapper return an array of people like example bellow: array ( array('name'=>'Jamie','age'=>'24'), array('name'=>'wellington', 'age'=>'42') ); If possible, i can put a datamapper result with engine template without any transformation. Thanks
[eluser]Kenshiro[/eluser]
Ok nevermind i thought you were using something like active record (or the vanilla DB class from CI) from what i read datamapper is OOP only.... Edit: if you are using this version of datamapper try this : http://www.overzealous.com/dmz/pages/ext...array.html It allows to convert your data to arrays. Hope it helps !
[eluser]FabricioFirmino[/eluser]
Thanks Summer Student, but I am not using this version of datamapper. My version is http://stensi.com/datamapper/. I'm think if is possible to use objects in template engine ( {person->name} ). Who know talk about it?
[eluser]FabricioFirmino[/eluser]
Sorry, change "Summer Student" in my last post for Kenshiro.
[eluser]cahva[/eluser]
You should really use the Overzealous version of datamapper. Its in active development(Stensi's datamapper was last updated in 2008) and has many improvements over the original.
[eluser]FabricioFirmino[/eluser]
You convince me to use other version, i didn't know that Stensi's version is not updated. Thank you kenshiro for show me the overzealous and cahva for show me precious informations about boths datamappers .
[eluser]danmontgomery[/eluser]
Just a side note here, you can always cast objects as arrays (and the other way around): Code: $foo->key = 'bar'; http://php.net/manual/en/language.types....ggling.php |
Welcome Guest, Not a member yet? Register Sign In |