View Full Version : AMFPHP - ODBC Solved ! :)

12-10-2003, 06:24 PM
A few days ago I was trying to use AMFPHP with ODBC connections but I had no luck :( , It seemed like Flash was not getting the recordset I was sending to it, or if it was getting it, it didnt know what to do with it.

If you take a look to the *recordSet.php files at /flashservices/sql/ dir you will notice that all of them are the same (same procedures), the only thing that changes are the functions for each DB connection type, and there is the mistake, ODBC does not use the same procedures to process a recordset as MySQL does, a few changes to the odbcRecordSet.php were needed in order to work properly with flash.

So, after some hours of hard work :) I finnaly got it working ! :) and here is the code, it might be useful to you some day :) Oh by the way im using it to connect to a Sybase DB, ... Im really excited about it :)


class odbcRecordSet
var $initialData = array();
var $columnNames = array();
function odbcRecordSet($d)
// count number of fields
$fieldcount = odbc_num_fields($d);
// grab all of the rows
while ($data = odbc_fetch_row($d)) {
$line = array();
for($i=1; $i<=$fieldcount; $i++){
$value = odbc_result($d, $i);
array_push($line, utf8_decode($value));
// add each row to the initial data array
$this->initialData[] = $line;
// grab the number of fields
// loop over all of the fields
for($i=1; $i<=$fieldcount; $i++){
// decode each field name ready for encoding when it goes through serialization
// and save each field name into the array
$this->columnNames[$i - 1] = utf8_decode(odbc_field_name($d, $i));
$this->numRows = odbc_num_rows($d);
?>If you take a look to the original odbcRecordSet.php you will notice some little changes. I hope you find it useful, and If you have any suggestions, comments, bugs, questions, etc... just let me know!

Cheers and happy flash remoting!


03-29-2004, 06:19 PM
can you show me an example php script that uses this class

04-01-2004, 05:12 PM
here is a little example..it's pretty simple and basic... you just need to edit the ODBC DSN info in the PHP file...

Hope it helps you...


Here is a little Description...

The flash app has an input text field where you type a query that you want to execute, once you send the query, the results you get are displayed in a data grid... that's it :) simple example to give you an idea...

07-16-2004, 11:28 AM
sorry to revive this thread but I've run into the same issue. I've attempted to apply mfalomir's solution to my project but it seems that the data that is returned into Flash is not exactly a RecordSet per se, its an object with characteristic similar to a RecordSet object. I implemented it as follows and the DataGrid(custList) was unable to display the data though the returned data came through. So, my question is, what's wrong here?

searchObj = new Object();
searchObj.getCustomerIDs_Result = function(result){
if(result != false){
colNames = result.getColumnNames();
custList.dataProvider = result;
trace("No results found");
test_mc.onRelease = function(){
var service = conn.getService("customer", searchObj);

function getCustomerIDs(){
$fields = array("custID",
$fieldList = implode(",", $fields);
$query = "select $fieldList from Customer";
if(!$conn = new sql()) return false;
$result = $conn->query($query);
return $rs = new odbcRecordset($result);