Returning query results from CodeIgniter models using AMFPHP, CI and FLASH
The previous example on Flash, AMFPHP and CodeIgniter basically demonstrates how to return a simple string value to your flash movie. It’s a good idea to read that before doing this.
The following example details how to return a recordset from your database query in your CodeIgniter model. Assuming you got the setup working on the first example, the following should be relatively straightforward.
Today I’ve managed to return a recordset from the database and display entries from that recordset.
I’ll just post the code and go through it line by line.
CodeIgniter model (listingsmodel.php)
AMFPHP Service Class (Press.php)
ActionScript 2 code
The code for the Model function and the AMFPHP service class are relatively straightforward. Lines 14-20 in the Actionscript2 code show how to access the array contents.
Line 16 displays everything that is past back as one huge nested array.
Line 17 displays just the data from the records in the database
Line 18 displays the length of the data array
Line 19 displays a specific value of the specified fieldname from the specified record
You can of course modify the code to do a loop that will utilise the array contents however you like.
Useful links
AS3 FLASH REMOTING EXAMPLE
RECORDSETS
OBJECTDUMPER
The previous example on Flash, AMFPHP and CodeIgniter basically demonstrates how to return a simple string value to your flash movie. It’s a good idea to read that before doing this.
The following example details how to return a recordset from your database query in your CodeIgniter model. Assuming you got the setup working on the [...]


July 13th, 2007 at 4:05 pm
Yes, I know I need to get a code plugin for the blog so I can actually post my code as text into my posts. So please forgive me (teh n00b) for posting the code as images.
July 25th, 2007 at 4:11 am
Good to know the tip on how to pass the values
August 1st, 2007 at 8:09 pm
good info
September 3rd, 2007 at 12:01 pm
hi - good hints for a starting point. is there also a way of using the codeigniter libraries?
or is it also possible to go he other way -> integrate amfphp into codeigniter (like the ci xmlrpc class)? anybody tried that?
September 4th, 2007 at 10:27 pm
I’m not entirely sure but i’d guess that it is possible. I’m fairly new to Code Igniter and post as I go along
If you find anything any where else please link to it.
Cheers.
September 14th, 2007 at 11:38 am
I found this excellent post that gives you an idea on how to convert the AS2 code shown here into a working AS3 equivalent. Very nice.
March 21st, 2008 at 12:15 am
Thanks for the info. One little thing I wanted to mention (and it’s obvious). AMFPHP creates its own method table with PHP5, but you still need to put the actual methods in your services file. I made the mistake of thinking that I could call methods in my CI model directly from flash. The services php file still needs the function to talk with the CI model.
March 21st, 2008 at 1:15 am
Hey Jacacado, thanks for the input. Glad you found this article helpful.