mfalomir
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 :)
odbcRecordSet.php
<?php
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;
unset($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!
Mario
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 :)
odbcRecordSet.php
<?php
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;
unset($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!
Mario