1 Reply Latest reply on Sep 5, 2011 8:40 AM by kokorito

    Flex+PHP

    ReboloMen

      I have a file you want to connect to a database and insert into the databaseMyPHPAdmin multiple serial numbers while the code I was using this but would not give me even to get all the serial numbers associated with a code material and then enter multiple serial numbers for a given product code.

       

      Please Help me the code is below ..

       

      Thank response ..

       

      <?php

       

      require_once("../util/Ligacao.php");

      require_once("../vo/MaterialFactorVo.php");

       

      class OperacoesMaterial

      {

       

      public $con;

       

       

      public function OperacoesMaterial()

      {

        $this->con    = new Ligacao();

      }

       

      public function findAll()

      {

      $query = "select * from material";

      $exec = mysql_query($query,$this->con->getConnection());

       

      $xml = '<?xml version="1.0" encoding="UTF-8"?><root>';

      while($dados = mysql_fetch_assoc($exec))

      {

                      $xml .= "<material_factor>";

                      $xml .= "<ID>".$dados['ID']."</ID>";

                      $xml .= "<Codigo>".$dados['Codigo']."</Codigo>";

                      $xml .= "<Descricao>".$dados['Descricao']."</Descricao>";

                      $xml .= "<ControlaStocks>".$dados['ControlaStocks']."</ControlaStocks>";

      $xml .= "<ValorMaterial>".$dados['ValorMaterial']."</ValorMaterial>";

      $xml .= "<StockRuptura>".$dados['StockRuptura']."</StockRuptura>";

      $xml .= "<Unidade>".$dados['Unidade']."</Unidade>";

      $xml .= "<UnidadeStockRuptura>".$dados['UnidadeStockRuptura']."</UnidadeStockRuptura>";

      $xml .= "<StockExistente>".$dados['StockExistente']."</StockExistente>";

      $xml .= "<CodigoLocalizacao>".$dados['CodigoLocalizacao']."</CodigoLocalizacao>";

      $xml .= "<TipoLocalizacao>".$dados['TipoLocalizacao']."</TipoLocalizacao>";

      $xml .= "<Data_Material>".$dados['Data_Material']."</Data_Material>";

      $sql2 = "select * FROM serie WHERE Cod_Material = ".$dados['Codigo']."";

      $exec_now = @mysql_query($sql2,$this->con->getConnection());

      $xml2 = '<root2>';

      if ($row = @mysql_fetch_assoc($exec_now))

      {

      $xml2 .= "<serie_factor>";

                     $xml2 .= "<ID>".$row['ID']."</ID>";

                     $xml2 .= "<Cod_Material>".$row['Cod_Material']."</Cod_Material>";

                     $xml2 .= "<Serie>".$row['Serie']."</Serie>";

                      $xml2 .= "</serie_factor>";

      }

      $xml2 .= "</root2>";

      $xml .= "<ArraySeries>".$xml2."</ArraySeries>";

                      $xml .= "</material_factor>";

      }

      $xml .= "</root>";

      return $xml;

      }

       

       

      public function insert(MaterialFactorVo $materialFactorVo)

      {

      $query = "INSERT INTO material (Codigo,".

      "    Descricao,".

      "    ControlaStocks,".

      "    ValorMaterial,".

      "    StockRuptura,".

      "    Unidade,".

      "    Data_Material,".

      "    CodigoLocalizacao,".

      "    TipoLocalizacao,".

      "    UnidadeStockRuptura,".

      "    StockExistente)".

      "   ".

      "VALUES ('$materialFactorVo->Codigo',".

      "   '$materialFactorVo->Descricao',".

      "   '$materialFactorVo->ControlaStocks',".

      "   '$materialFactorVo->ValorMaterial',".

      "   '$materialFactorVo->StockRuptura',".

      "   '$materialFactorVo->Unidade',".

      "   '$materialFactorVo->Data_Material',".

      "   '$materialFactorVo->CodigoLocalizacao',".

      "   '$materialFactorVo->TipoLocalizacao',".

      "   '$materialFactorVo->UnidadeStockRuptura',".

      "   '$materialFactorVo->StockExistente')";

      for($c = 0; $c < count($materialFactorVo->ArraySeries); $c++)

      {  

      $sql="INSERT INTO serie (Cod_Material,"."Serie)"".""."VALUES ('".$materialFactorVo->ArraySeries[c]->Cod_Material."',"."'".$materialFactorVo->ArraySeri es[c]->Serie."')";

      $exec2 =  @mysql_query($sql,$this->con->getConnection());

      }

      $exec =  mysql_query($query,$this->con->getConnection());

       

      if ($exec)$hasExecute = "true"; else   $hasExecute  = "false";

        

      $xml = "<root>";

      $xml .= "<material_factor>";

      $xml .= "<insert>".$hasExecute."</insert>";

      $xml .= "</material_factor>";

      $xml .= "</root>";

       

      return $xml;

       

       

      }

       

       

      public function delete(MaterialFactorVo $materialFactorVo)

      {

      $query = "DELETE FROM material WHERE ID = $materialFactorVo->ID";

       

      $exec =  mysql_query($query,$this->con->getConnection());

       

      if ($exec) $hasExecute = "true"; else   $hasExecute  = "false";

        

      $xml = "<root>";

      $xml .= "<material_factor>";

      $xml .= "<remove>".$hasExecute."</remove>";

      $xml .= "</material_factor>";

      $xml .= "</root>";

       

      return $xml;

       

      }

      }

       

      ?>