1

zendphpを介してflexをMySqlに接続するのに苦労しています。HTTPサービスを使用した例をいくつか見ました。私の質問は次のとおりです

1)3つのテーブルだけで、単純な挿入と更新のみを実行しています。それで、これを達成するためにそれらすべてのZend AMFを使用する必要がありますか?2)それ以外の場合、HTTPServiceの使用はどうですか?

表示はzendAMFを使用した最も簡単な操作でしたが、値を挿入しようとすると迷子になりました。

データベースフィールド変数を格納するためにphpファイルvo.phpを使用しましたが、メインのphpファイルでrequire_once関数を使用できませんでした

これはvo.phpです

    class vo {

        public $id;
        public $username;
        public $symptom;
        public $number_of_times_tested;
        public $original_image;
        public $sequence_of_actions;
        public $customized_image;
        public $percieved_image;
    }

これはpatientServiceファイルです

//require_once 'vo.php';

class patientService { 
  var $username = "root"; 
  var $password = ""; 
  var $server = "localhost"; 
  var $port = "3306"; 
  var $databasename = "patient"; 
  var $tablename = "records"; 

  var $connection; 
  public function __construct() { 
    $this->connection = mysqli_connect( 
                       $this->server,  
                       $this->username,  
                       $this->password, 
                       $this->databasename, 
                       $this->port); 

    $this->throwExceptionOnError($this->connection); 
  } 

  public function getpatient() {
     $stmt = mysqli_prepare($this->connection,
          "SELECT
              records.id,
              records.username,
              records.symptom,
              records.number_of_times_tested,
              records.original_image,
              records.sequence_of_actions,
              records.customized_image,
              records.percieved_image
            FROM records");     

      $this->throwExceptionOnError();

      mysqli_stmt_execute($stmt);
      $this->throwExceptionOnError();

      $rows = array();
      mysqli_stmt_bind_result($stmt, $row->id, $row->username,
                    $row->symptom, $row->number_of_times_tested, $row->original_image,  $row->sequence_of_actions, $row->customized_image, $row->percieved_image
                    );

      while (mysqli_stmt_fetch($stmt)) {
          $rows[] = $row;
          $row = new stdClass();
          mysqli_stmt_bind_result($stmt, $row->id, $row->username,
                    $row->symptom, $row->number_of_times_tested, $row->original_image,  $row->sequence_of_actions, $row->customized_image, $row->percieved_image
                    );

      }

      mysqli_stmt_free_result($stmt);
      mysqli_close($this->connection);

      return $rows;
  }  
/* create a entry for database patient 
*/
    public function createPatient($item) {
    $stmt = mysqli_prepare($this->connection,
        "INSERT INTO patient (
            id,username,symptom,number_of_times_tested,original_image,sequence_of_actions,  
            customized_image,percieved_image) 
        VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
    $this->throwExceptionOnError();


    mysqli_bind_param($stmt, $item->id , $item->username, $item->symptom,$item->number_of_times_tested,$item->original_image,
        $item->sequence_of_actions, $item->customized_image, $item->percieved_image
    );

    $item->id = '5';
    $item->username = 'abhilash';
    $item->symptom = 'retina pigmentosa'; 
    $item->number_of_times_tested = '3';
    $item->original_image = 'img';
    $item->sequence_of_actions = 'l1l2l2lr3';
    $item->customized_image = 'img';
    $item->percieved_image = 'img';

    $this->throwExceptionOnError();



    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();


    $autoid = mysqli_stmt_insert_id($stmt);


    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);

    return $autoid;
  }

誰かが良い詳細な例へのリンクを与えることができますか?だから私はよりよく参照して理解することができますか?

4

1 に答える 1

0

HTTPServiceは、Flex内のあらゆる種類のHTTPリソースを要求するために使用されます。必要に応じて、テーブルで必要な操作を実行する独自のJSonまたはXMLベースのWebサービスを設計できます。この戦略はフロントエンドに依存せず、フロントエンドテクノをFlexからHTML / Ajaxに切り替えることを選択した場合、たとえば、バックエンドで変更を行う必要はありません。

もう1つの解決策は、Zend_AMFを使用して、FlexからAMFを介してPHPオブジェクトと直接対話できるようにすることです。

私は常に最初のソリューションを使用することを好みましたが(私が何をしているのかをよく理解したことほど興味深い理由はありません)、フレックスのみのフロントエンドを使用する場合は、2番目のソリューションで生産性が向上するはずです。

于 2011-11-26T23:19:56.293 に答える