Flex PHP service

348 views Asked by At

Already tearing my hairs out for a couple of days. There is not much left of them ;-)

I am experiencing a strange problem when I want to bind a service to a button or something else:

files: - CDPC.php

<?php

require_once ('VOcdpc.php');

class CDPC {

    var $username = "root";
    var $password = "";
    var $server = "localhost";
    var $port = "3306";
    var $databasename = "xoffercommon";
    var $tablename = "tblcity";

    var $connection;

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

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

    public function getCDPC($cityID) {

        $con = mysql_connect("localhost","root","");
        if (!$con)
       {
            die('Could not connect: ' . mysql_error());
        }

        mysql_select_db("xoffercommon", $con);

        $cdpc_Id = new Vocdpc();
        $cdpc_Id->id_cdpc = 1;
        $cdpc_Id->city_Id=$cityID;

        $result_prov = mysql_query("SELECT tblProvence_Id FROM tblCity WHERE Id = " . $cityID);
        $row = mysql_fetch_array($result_prov);
        $cdpc_Id->provence_Id=intval($row['tblProvence_Id']);

        $result_dist = mysql_query("SELECT tblDistrict_Id FROM tblProvence WHERE Id = " . $cdpc_Id->provence_Id);
            $row = mysql_fetch_array($result_dist);
        $cdpc_Id->district_Id=intval($row['tblDistrict_Id']);

        $result_coun = mysql_query("SELECT tblCountry_Id FROM tblDistrict WHERE Id = " . $cdpc_Id->district_Id);
            $row = mysql_fetch_array($result_coun);
            $cdpc_Id->country_Id=intval($row['tblCountry_Id']);

            return $cdpc_Id;
            mysql_close($con);
    }

    private function throwExceptionOnError($link = null) {
        if($link == null) {
                $link = $this->connection;
        }
        if(mysqli_error($link)) {
            $msg = mysqli_errno($link) . ": " . mysqli_error($link);
                throw new Exception('MySQL Error - '. $msg);
            }       
    }
}
?>

VOcpdc.php

 <?php
 class VOcdpc
 {
     public $id_cdpc;
     public $country_Id;
     public $district_Id;
     public $provence_Id;
     public $city_Id;
     // explicit actionscript class
     var $_explicitType = "Vocdpc";
 }
 ?>

In flex builder

I can add the services to the Data Services panel but I have two strange things:

1) when I want to configure the return type he doesn't let me create a new ValueObject type, I only get the bottom datagrid which states: Properties returned by the operation: Property: country_Id, provence_Id, city_Id, id_cdpc, district_Id with the related values on the right side. Why can't I create a new data type on the top?

2) When I accept this and want to add the service call to a button (drag&drop) I get the following error: Error occurred while generating code. Make sure that there are no compiler eroors and try again after reopening the file. Componentn type services.cdpc.CDPC not found...

(ps: When I perform a Test Operation everything seems to be ok, I get the expected output values)

1

There are 1 answers

0
Wimmerke On

this is the class included in the main cdpc.php file, the post drops it apparently, so here is the VOcpdc file:

// explicit actionscript class
var $_explicitType = "Vocdpc";

} ?>