Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Como chamar um método de uma classe em PHP

Jose_Vieira_Silva
473 Views

Guys, please help me!

I have a generic class with CRUD in PHP, I would like to use it with the Intel XDK. But I do not know how to call the methods of that class.

The CRUD methods take an array with data and a string stating the DB table as parameters, eg:

   class CRUD_Generico {

    / * ------------------------------------------------ -
     * CRUD_Generico.php
     * INSERT NEW ITEM ON THE TABLE
     *author: Vieira - Belo Horizonte-MG
     * ------------------------------------------------- -

   * /
     public function getAllDados ($ table, $ where) {
            $ db = $ this-> connection ();
            $ query = "SELECT * FROM $ table";
            if ($ where! = "") {
               $ query = $ where.;
            }

            // Does the query on the table and returns an object;
            // ------------------------------------------------ -
             return $ object;

   }

    public function addItem ($ table, $ data) {
            $ db = $ this-> connection ();

            // Does the inclusion in the table and returns an "OK";
            // ------------------------------------------------ -

              return "OK";
        }

  }

How to use this class in Intel XDK?

Can someone help me?

Abs.

 

Pessoal, me ajude por favor!

Tenho uma classe genérica com CRUD em PHP, gostaria de utilizá-la com o Intel XDK. Porém não sei como fazer a chama dos métodos dessa classe.

Os métodos CRUD recebem um array com os dados e uma string informando a tabela do BD como parâmetros, exemplo:

   class CRUD_Generico {

    /* --------------------------------------------------
     *  CRUD_Generico.php
     *  INSERIR NOVO ITEM NA TABELA
     *  @author: Vieira - Belo Horizonte -MG
     * --------------------------------------------------

   */
     public function getAllDados($tabela, $where){
            $db = $this->connection(); 
            $consulta = "SELECT * FROM $tabela ";
            if ($where !="") {
               $consulta .= $where;  
            }

            // Faz a consulta na tabela e retorna um objeto;
            //-------------------------------------------------
             return  $objeto;

   }

    public function addItem($tabela, $dados) {
            $db = $this->connection();

            // Faz a inserção na tabela e retorna um "OK";
            //-------------------------------------------------

              return  "OK";
        }

  }

Como utilizar essa classe no Intel XDK?

Alguém pode me ajudar?

Abs.

 

0 Kudos
1 Reply
Swati_S_Intel1
Employee
473 Views

Your PHP code would be running on server and Intel XDK creates client side app. So, what you need to do is :

1) On server side create a webservice using PHP that can serve a GET or POST request 

2) Use AJAX within your XDK app to get data from your webservice.

0 Kudos
Reply