[TYPO3-extbase] Get field values from database with AJAX

Graf Zahl graf_zahl348 at hotmail.de
Wed May 23 13:37:13 CEST 2012


Hello together,I am still new to Extbase Development, but I am slowly proceeding, I even managed to get an AJAX call in my Extension, so I can output some stuff dynamically.However, to make this useful, I would like to read out some fields from my database and comfortably put them in an array and encode it in JSON. I managed to do the JSON encoding with random values in an array, 
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);return json_encode($arr);
but I don't seem to understand how to use the repository correctly for some output. I'm not talking about the Fluid View here, I'd rather not use it here.
So what I basically tried was
$myarray = $this->raceRepository->findAll();print_r($myarray);
I just wanted any output (that's why I used print_r), but I got a lot more than what I wanted, including some error message like"You should never see this warning. If you do, you probably used PHP array functions like current() on the Tx_Extbase_Persistence_QueryResult. To retrieve the first result, you can use the getFirst() method."
I don't even know where to start, that might be my biggest problem here. Can I somehow use the getMethods I declared in the Model?
Hope you can help me :)
Regards,Zahl 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.typo3.org/pipermail/typo3-team-extbase/attachments/20120523/fcda9e6c/attachment.htm>


More information about the TYPO3-team-extbase mailing list