PDA

View Full Version : Extremely slow amfphp db execution


clem_c_rock
05-06-2004, 01:44 PM
Hello - I building a complex flash applicationn w/ a great deal of flash remoting using amfphp.

I'm having good luck w/ the project but, I noticing some of my db calls to my amfphp class are very slow. Here's a section of the code that is rather slow: I know there's something that could speed this thing up because there are other examples of amfphp making heavy db calls and it is very fast. For example:http://www.sephiroth.it/test/PHP_re...orum/index.html. This example is very db heavy. Some of my db calls are taking up to 7 seconds to exacute.


Here is the actionscript:

====== Actionscript code ===============================================
#include "init.as"
#include "NetDebug.as"
#include "NetServices.as"


//===== remoting data calls ACTIONSCRIPT CODE ========================================
main_responder = new Object();


//---- add update responder ----------------------------------------------
main_responder.delete_segment_Result = function( result )
{
get_conversation_segments( txt_conversation_id );
}
//-------------------------------------------------------------------------

main_responder.onStatus = function ( data )
{
txt_output += "\n error occurred-->>" + data + "\n line: " + data.line + " || description: " + data.description;
}
//================================================== =======================================


//==== SET UP OUR REMOTE CONNECTIONS ===============================
NetServices.setDefaultGatewayUrl("gateway.php");
var conn = NetServices.createGatewayConnection();
service = conn.getService("products", main_responder );
//================================================== ================

swf_form = new Object();
swf_form.click = function( evt )
{
if( evt.target == delete_button )
{
service.delete_segment( clip_info_input.txt_selected_segment_id ); first remote call
}
}

delete_button.addEventListener("click", swf_form);
list_grd.addEventListener("cellPress", swf_form);
//================================================== =============================

Here's a full blown example of the php code:


class products extends verify_login
{
var $dbhost = "localhost";
var $dbname = "scopedb";
var $dbuser = "scopeprogram";
var $dbpass = "sc0pic_db";
function products()
{
$this->methodTable = array
(
"delete_segment" => array
(
"description" => "Delete Selected Segment",
"access" => "remote" ,
"arguments" => array ('segment_id' )
)
)
);

#---- delete segment function ----------------------------------------------------------------------
function delete_segment( $segment_id )
{
$delete_segment = "DELETE FROM segment WHERE segment_id = $segment_id ";
$result_delete_segment = mysql_query( $delete_segment, $this->conn );
if(!$result_delete_segment){ $error = true; }

if(!$error){ return " Successfull Delete"; }else{ return "Error"; }
}
#------------------------------------------------------------------------------------------------------

}//end_class



Thanks for any help you can offer

Clem C