示例#1
0
 public function readUnits()
 {
     $con = self::openConnection();
     $measurements = new Measurements();
     mysqli_begin_transaction($con);
     $sql = "SELECT * FROM measurement WHERE 1";
     $res = mysqli_query($con, $sql);
     while ($arrRes = mysqli_fetch_assoc($res)) {
         $measurement = new Measurement();
         $measurement->setId($arrRes['id']);
         $measurement->setCode($arrRes['code']);
         $measurements->setUnit($measurement);
     }
     return $measurements;
 }
示例#2
0
 public function parseMeasurements()
 {
     $measurements = new Measurements();
     $keyParams = array();
     foreach ($this->xmlProducts as $product) {
         $bmu = $product->getBasicMeasurementUnit();
         $mu = $product->getMeasurementUnit();
         if (!empty($bmu) && !in_array($bmu, $keyParams)) {
             $measurement = new Measurement();
             $measurement->setCode($bmu);
             $measurements->setUnit($measurement);
             array_push($keyParams, $bmu);
         }
         if (!empty($mu) && !in_array($mu, $keyParams)) {
             array_push($keyParams, $mu);
             $measurement = new Measurement();
             $measurement->setCode($mu);
             $measurements->setUnit($measurement);
         }
     }
     $measurementDAO = new MeasurementDAO();
     $measurementDAO->insertUnits($measurements);
     $measurements = $measurementDAO->readUnits();
     return $measurements;
 }