| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Dec 2003
Location: Hermosillo, Mexico
Posts: 52
|
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 Code:
<?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);
}
}
?>
Cheers and happy flash remoting! Mario |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Mar 2004
Posts: 1
|
can you show me an example php script that uses this class
|
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Dec 2003
Location: Hermosillo, Mexico
Posts: 52
|
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... http://www.cybermundos.com/pruebas/r...g/odbcTest.zip 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... |
|
|
|
|
|
#4 |
|
Defender of Obviousness
Join Date: Dec 2003
Posts: 21
|
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?
PHP Code:
PHP Code:
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|