Re: [flexcoders] AMFPHP Question

2009-03-21 Thread Alan K
Last time I made a data driven app with AMFPHP. I used PHP and MySQL.  I did
all of what your describing within PHP and MySQL.

Everytime I querried the database, I always sent back the same kind of
object to Flex.  The object always had two properties, a Œsuccess¹ property
and a Œmessage¹ property. IF the query succeeded, then my object that I
created in PHP would be:

Œsuccess¹ = true; Œmessage¹ = query executed successfully.

Or if it failed it would be.

Œsuccess¹ = false; Œmessage¹ = [enter your custom error message here. I.e.
Œrecord already exists¹]

 I suggest making your remote object responses in a format that you repeat,
like this:

mx:RemoteObject id=myRemoteObject
 mx: method name =insertRecord result
=¹_onInsertRecordResponse(event)/
mx:RemoteObject/


private function _onInsertRecordResponse (evt:ResultEvent) : void
 {

if(evt.result.success) // remember I¹m returning an object with a
Œsuccess¹ and a Œmessage¹
{
Alert.show(event.result.message) // output Œquery execurted
seccessfully¹
} 
Else if (!evt.result.success)
{
Alert.show(event.result.message) // outputs Œrecord already exists¹
// my custom error message I made in PHP
}
}

This way, every result handler, from every remote object is in my app is
structured the same way.

Alan


[flexcoders] AMFPHP Question

2009-03-20 Thread secrit.service

Hi all,

I have following issue, which I don't understand.

I created a button which will add a record to the database. But before
doing so I need to check if a similar record already exists.
This is how I thought it could be solved:

mx:RemoteObject id=myRemoteObject
  mx: method name =existRecord result
=recordExistResultHandler(event)/
mx:RemoteObject/

if (myRemoteObject.existRecord.send(myRecord)) {
  Alert.show (Record already exists)
} else {
 // Insert record into the database
  myRemoteObject.insertRecord.send(myRecord)
}


private function recordExistResultHandler (evt:ResultEvent) : Boolean {


  Alert.show (Result getting back from webserver is  +
evt.result.toString());
  return evt.result;

}


The function existRecord on the webserver checks if a similar record
already exists and sends a Boolean back. This works fine.
To my opinion this should work as follows (supposing record is already
in the database) :
- Before executing my if-statement, it will check the condition (check
if record already exists)
- it send a request existSpell to the webserver which will query the
database
- num_rows is greater dan zero (meaning record already exists), the
webserver will return TRUE to the resultHandler of flex-application
- resultHandler is executed -- an Alert-windows appears telling Result
getting back ...is TRUE  and the value is returned to the
if-statement.
- Because condition is true -- an Alert-window appears telling Record
already exists

BUT ... THIS IS NOT HOW IT WORKS ?
As a matter of fact the if-statement is executed first (Alert 'Record
already exists') and afterwards I get the Alert telling the result of
the webserver???
It's the opposite world.

Am I missing something??

Thanks



RE: [flexcoders] AMFPHP Question

2009-03-20 Thread Tracy Spratt
ALL RPC data service calls, including RemoteObject are *asynchronous*.  And
such calls are non-blocking.  You must invoke your check call, then, in its
result handler, do the conditional logic to  invoke the insert.

 

Tracy Spratt,

Lariat Services, development services available

  _  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of secrit.service
Sent: Friday, March 20, 2009 2:19 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] AMFPHP Question

 

Hi all,

I have following issue, which I don't understand.

I created a button which will add a record to the database. But before doing
so I need to check if a similar record already exists.
This is how I thought it could be solved:

mx:RemoteObject id=myRemoteObject
 mx: method name =existRecord result
=recordExistResultHandler(event)/
mx:RemoteObject/

if (myRemoteObject.existRecord.send(myRecord)) {
 Alert.show (Record already exists)
} else {
// Insert record into the database
 myRemoteObject.insertRecord.send(myRecord)
}


private function recordExistResultHandler (evt:ResultEvent) : Boolean {

 Alert.show (Result getting back from webserver is  +
evt.result.toString());
 return evt.result;

}

The function existRecord on the webserver checks if a similar record already
exists and sends a Boolean back. This works fine.
To my opinion this should work as follows (supposing record is already in
the database) :
- Before executing my if-statement, it will check the condition (check if
record already exists)
- it send a request existSpell to the webserver which will query the
database
- num_rows is greater dan zero (meaning record already exists), the
webserver will return TRUE to the resultHandler of flex-application
- resultHandler is executed -- an Alert-windows appears telling Result
getting back ...is TRUE  and the value is returned to the if-statement.
- Because condition is true -- an Alert-window appears telling Record
already exists

BUT ... THIS IS NOT HOW IT WORKS ?
As a matter of fact the if-statement is executed first (Alert 'Record
already exists') and afterwards I get the Alert telling the result of the
webserver???
It's the opposite world.

Am I missing something??

Thanks





[flexcoders] AMFPHP Question -- Flex 2

2007-03-06 Thread Mike and Stephie
Hi People !
Just following through Mike Potter's example of integrating AMFPHP with 
Flex2, notice that with the following code
http://www.adobe.com/devnet/flex/articles/flex2_amfphp_03.html
Flex cannot recognize the

gateway = new RemotingConnection( http://localhost/flex/php/gateway.php; );

line -- it thinks that there is no RemotingConnection method.

Does anyone have any ideas?
Also does anyone know of sample code which demonstrates adding editing deleting 
 records as well ?
Thanks for any help
Prema