Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Flash Remoting

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-10-2003, 07:24 PM   #1
mfalomir
Registered User
 
Join Date: Dec 2003
Location: Hermosillo, Mexico
Posts: 52
Talking AMFPHP - ODBC Solved ! :)

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);
	}
}
?>
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
mfalomir is offline   Reply With Quote
Old 03-29-2004, 07:19 PM   #2
peanutbware
Registered User
 
Join Date: Mar 2004
Posts: 1
Default

can you show me an example php script that uses this class
peanutbware is offline   Reply With Quote
Old 04-01-2004, 06:12 PM   #3
mfalomir
Registered User
 
Join Date: Dec 2003
Location: Hermosillo, Mexico
Posts: 52
Default

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...
mfalomir is offline   Reply With Quote
Old 07-16-2004, 12:28 PM   #4
bianster
Defender of Obviousness
 
Join Date: Dec 2003
Posts: 21
Default

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:
searchObj = new Object();
searchObj.getCustomerIDs_Result = function(result){
    if(
result != false){
        
colNames result.getColumnNames();
        
custList.dataProvider result;
    }
    else{
        
trace("No results found");
    }
}
test_mc.onRelease = function(){
    var 
service conn.getService("customer"searchObj);
    
service.getCustomerIDs();

PHP Code:
function getCustomerIDs(){
        include(
"../library/sql.php");
        include(
"../library/odbcRecordset.php");
        
$fields = array("custID",
                        
"firstName",
                        
"lastName");
        
$fieldList implode(","$fields);
        
$query "select $fieldList from Customer";
        if(!
$conn = new sql()) return false;
        
$result $conn->query($query);
        return 
$rs = new odbcRecordset($result);

bianster is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.