Test Operation with Flash Builder and Zend AMF on mysql utf8 database

The problem occurs when there are accented characters in an utf8 database (particularly common in french).
The generated service works properly, but cannot be tested in Test Operation view.
Flash Builder displays an error advising to encode the content with the php method utf8_encode ()…

“InvocationTargetException:There was an error while invoking the operation. Check your operation inputs or server code and try invoking the operation again.
Reason: An error occured while reading response sent by server. Try encoding the response suitably before sending it. e.g. If a database column contains UTF-8 characters then use utf8_encode() to encode its value before returning it from the operation.

Oh ? Really ?
After some test I remember what I always do before performing queries… And what is not in the Flash Builder generated service… Character set definition.

 
$stmt = mysqli_prepare($this->connection, "SET NAMES UTF8;");
$this->throwExceptionOnError();
 
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();

To put in the constructor.

Leave a Reply

Your email address will not be published. Required fields are marked *