Ejemplo n.º 1
0
 public function insertOrUpdateProduct($post)
 {
     parent::createConnection();
     $house_no = $post['house_no'];
     $street_name = parent::getEscaped($post['street_name']);
     $apartment_no = parent::getEscaped($post['apartment_no']);
     $city = parent::getEscaped(ucwords($post['city']));
     $state = $post['state'];
     $country = $post['country'];
     $zip = strtoupper($post['zip']);
     $type = $post['range'];
     $description = parent::getEscaped($post['description']);
     $room_no = $post['rooms'];
     $bath_no = $post['bathrooms'];
     $living_room_no = $post['living_rooms'];
     $price = parent::getEscaped($post['price']);
     $rangeType = $post['rangeType'];
     $loginObj = new Login();
     $user_id = $loginObj->getUserId();
     if (isset($post['upload']) && isset($_FILES['files'])) {
         $query1 = "INSERT INTO address_info VALUES (DEFAULT, '{$house_no}', '{$street_name}', '{$apartment_no}', '{$city}', '{$state}', '{$zip}', '{$country}')";
         parent::executeSqlQuery($query1);
         $addressId = parent::getLastId();
         $query = "INSERT INTO dwellings VALUES (DEFAULT, '{$addressId}', '{$user_id}', '{$type}', '{$description}', '{$room_no}', '{$bath_no}', '{$living_room_no}', '{$price}', '{$rangeType}')";
         parent::executeSqlQuery($query);
         $this->uploadImages($_FILES);
     } elseif (isset($post['update'])) {
         $dwelling_Id = $post['hiddenID'];
         $address_id = $this->getAddressId($dwelling_Id);
         $updateDwellings = "UPDATE dwellings SET type \t\t \t\t= '{$type}',    \t\tdescription \t= '{$description}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t no_of_rooms \t\t= '{$room_no}', \t\tno_of_bathrooms\t= '{$bath_no}', \t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t     no_of_living_rooms = '{$living_room_no}',price \t\t\t= '{$price}'\n\t\t\t\t\t\t\t\t\t\t\t\t   WHERE dwelling_Id = {$dwelling_Id}";
         $updateAddress = "UPDATE address_info SET house_no \t\t\t= '{$house_no}', \t\tstreet_name  \t\t= '{$street_name}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t    apartment_no \t\t= '{$apartment_no}', \tcity \t\t \t\t= '{$city}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t    province \t\t\t= '{$state}', \t\tzip_code \t \t\t= '{$zip}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t    country\t\t\t\t= '{$country}'\n\t\t\t\t\t\t\t\t\t\t\t      WHERE address_id \t= '{$address_id}'";
         parent::executeSqlQuery($updateDwellings);
         parent::executeSqlQuery($updateAddress);
     }
 }
Ejemplo n.º 2
0
 /**
  * Drops a table
  *
  * @return bool|mysqli_result   Result of query
  */
 public function drop()
 {
     return parent::createConnection()->query('DROP TABLE ' . $this->name);
 }
Ejemplo n.º 3
0
 public function getUserId()
 {
     $selectUserId = "SELECT user_id FROM users WHERE username = '******'USERNAME'] . "'";
     $rs = mysqli_query(parent::createConnection(), $selectUserId);
     if ($rs->num_rows > 0) {
         while ($row = $rs->fetch_assoc()) {
             $user_id = $row['user_id'];
         }
         return $user_id;
     }
     return null;
 }