function Add_Building(Building $building)
 {
     $name = $building->getName();
     $name_amharic = $building->getNameAmharic();
     $building_description = $building->getBuildingDescription();
     $building_description_amharic = $building->getBuildingDescriptionAmharic();
     $parking_area = $building->getParkingArea();
     $query = "INSERT INTO building(Name,Name_Amharic,Building_Description,Building_Description_Amharic,Parking_Area) VALUES('{$name}','{$name_amharic}','{$building_description}','{$building_description_amharic}',\n'{$parking_area}')";
     $result = mysqli_query($this->getDbc(), $query);
     if ($result) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Exemplo n.º 2
0
 function Edit_Building(Building $Building, $BUL_ID, Place $Place, $Place_ID, Direction $Dir, $Direction_ID)
 {
     //start the transaction
     $query1 = "START TRANSACTION";
     $result1 = mysqli_query($this->getDbc(), $query1);
     $Building_Name = $Building->getName();
     $Building_Name_Amharic = $Building->getNameAmharic();
     $Building_Description = $Building->getBuildingDescription();
     $Building_Description_Amharic = $Building->getBuildingDescriptionAmharic();
     $Parking_Area = $Building->getParkingArea();
     $Building_ID = $BUL_ID;
     //now edit the company;
     $query2 = "Update Building set\n\t\tName='{$Building_Name}',Name_Amharic = '{$Building_Name_Amharic}'\n\t\t,Building_Description='{$Building_Description}'\n\t\t,Building_Description_Amharic='{$Building_Description_Amharic}',\n\t\tParking_Area='{$Parking_Area}' where ID='{$Building_ID}'";
     $result2 = mysqli_query($this->getDbc(), $query2);
     if ($result2) {
         echo "result 2";
     }
     //edit the place
     $Region_ID = $Place->getRegionID();
     $City_ID = $Place->getCityID();
     $Sub_City_ID = $Place->getSubCityID();
     $Wereda_ID = $Place->getWeredaID();
     $Sefer_ID = $Place->getSeferID();
     $Street_ID = $Place->getStreetID();
     $query3 = "update place set\n\t\t\t\tRegion='{$Region_ID}',City='{$City_ID}',Sub_City='{$Sub_City_ID}',Wereda='{$Wereda_ID}',Sefer='{$Sefer_ID}',Street='{$Street_ID}'\n\t\t\t\twhere ID='{$Place_ID}'";
     $result3 = mysqli_query($this->getDbc(), $query3);
     if ($result3) {
         echo "result 3";
     }
     //update direction
     $Direction = $Dir->getDirection();
     $Direction_Amharic = $Dir->getDirectionAmharic();
     $query4 = "update direction set\n\t\t\t\t\tDirection='{$Direction}',Direction_Amharic='{$Direction_Amharic}'\n\t\t\t\t\twhere ID='{$Direction_ID}'";
     $result4 = mysqli_query($this->getDbc(), $query4);
     if ($result4) {
         echo "result 4";
     }
     if ($result1 and $result2 and $result3 and $result4) {
         $query_last = "COMMIT";
         mysqli_query($this->getDbc(), $query_last);
         return TRUE;
     } else {
         $query_last = "ROLLBACK";
         mysqli_query($this->getDbc(), $query_last);
         return FALSE;
     }
 }