2 Replies Latest reply on Dec 10, 2011 7:03 AM by quilmex

    Several services a single connection

    quilmex

      I created a Flash Builder 4.5 services (type of service PHP) with the wizard. These services are connected to a database. The services work perfectly. The problem is that the wizard gives me the data connection to the database each service.

      Is there any way that the connection data of the database are not in all services?

       

      I tried putting in PHP (service):

      1. include('db.php')
      2. require_once

       

      But has not worked

        • 1. Re: Several services a single connection
          drkstr_1 Level 4

          If you are looking for programming advice, please post some sample code and explain what you are trying to achieve with it.

          • 2. Re: Several services a single connection
            quilmex Level 1

            when generating the PHP service:

             

            CreateService.png

             

            I created a file "CategoriaService.php", this has the following code:

             

            class CategoriaService {

             

                var $username = "XXXXXX";

                var $password = "XXXXXXXXXXX";

                var $server = "XXXXXXXXXXXXXXXXX";

                var $port = "3306";

                var $databasename = "XXXXXXXXXXXXX";

                var $tablename = "categoria";

             

                var $connection;

             

                /**

                 * The constructor initializes the connection to database. Everytime a request is

                 * received by Zend AMF, an instance of the service class is created and then the

                 * requested method is invoked.

                 */

                public function __construct() {

                      $this->connection = mysqli_connect(

                                              $this->server, 

                                              $this->username, 

                                              $this->password,

                                              $this->databasename,

                                              $this->port

                                          );

             

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

                }

            ....................

             

            And when i create a new service:

             

            CreateServiceII.png

            It creates a service with data connection to the database again

             

             

            class UsuarioService {

             

                var $username = "XXXXXXX";

                var $password = "XXXXXX";

                var $server = "XXXXXXXXXXXXXXXX";

                var $port = "3306";

                var $databasename = "XXXXXXXXXXXX";

                var $tablename = "usuario";

             

                var $connection;

             

                /**

                 * The constructor initializes the connection to database. Everytime a request is

                 * received by Zend AMF, an instance of the service class is created and then the

                 * requested method is invoked.

                 */

                public function __construct() {

                      $this->connection = mysqli_connect(

                                              $this->server, 

                                              $this->username, 

                                              $this->password,

                                              $this->databasename,

                                              $this->port

                                          );

             

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

                }

            ................................

             

            If change the data connection will have to change all services. Is there any way that the connection data of the database are not in all services?