public function update($package) { $con = new bd(); $sql = "UPDATE package SET id_city=" . $package->getIdCity() . ", name='" . $package->getName() . "', " . "description='" . $package->getDescription() . "', price=" . $package->getPrice() . ", " . "price_promo=" . $package->getPricePromo() . ", date_start='" . $package->getDateStart() . "', date_end='" . $package->getDateEnd() . "', " . "id_user="******", thumbnail='" . $package->getThumbnail() . "' WHERE idpackage=" . $package->getIdPackage(); $r = $con->prepare($sql); $r->execute(); }
public function subir($ar, $ex, $dir) { $this->dir = $dir; $this->archivo = explode(".", $ar['name']); $this->extensiones = $ex; $random = date("d:m:y:h:i") * rand() * 9999999; if (in_array($this->archivo[1], $this->extensiones)) { $this->url = $dir . $random . "." . $this->archivo[1]; if (!file_exists($this->dir)) { @mkdir($this->dir, 777); } $this->arr = array(':nombre' => "hola", ':des' => "Hola", ':url' => $this->url); $this->archivo = $ar; if (move_uploaded_file($this->archivo['tmp_name'], $this->url)) { $base = new bd(TBD, SER, BD, US, CL); $i = 1; $sql = $base->prepare("INSERT INTO imagen(idimagen, nombre, ruta, foto) VALUES ({$i}+1, {$this->archivo}[1], {$this->url}, {$this->archivo}['tmp_name'])"); if ($sql->execute($this->arr)) { echo "Imagen subida y almacenada correctamente"; } else { echo "Error"; } } else { echo "error"; } } else { echo "Extension invalida"; } }
public function insert($city) { $con = new bd(); $sql = 'INSERT INTO city (name, state, country, description, thumbnail, id_gallery, id_user) VALUES ' . '("' . $city->getName() . '", "' . $city->getState() . '", ' . '"' . $city->getCountry() . '", "' . $city->getDescription() . '", ' . '"' . $city->getThumbnail() . '", ' . $city->getIdGallery() . ', ' . $city->getIdUser() . ')'; $r = $con->prepare($sql); $r->execute(); }
public function insert($form) { $con = new bd(); $sql = "INSERT INTO form_interest (id_package, first_name, last_name, guests_number, couple_room, individual_room, double_room, triple_room, observation, email, area_code, phone, newsletter) VALUES " . "(" . $form->getIdPackage() . ", '" . $form->getFirstName() . "', " . "'" . $form->getLastName() . "', " . $form->getGuestsNumber() . ", " . $form->getCoupleRoom() . ", " . $form->getIndividualRoom() . ", " . $form->getDoubleRoom() . ", " . $form->getTripleRoom() . ", '" . $form->getObservation() . "', '" . $form->getEmail() . "', " . $form->getAreaCode() . ", " . $form->getPhone() . ", " . $form->getNewsletter() . ")"; $r = $con->prepare($sql); $r->execute(); }
public function getUser($login, $password) { $con = new bd(); $sql = 'Select * from user where login="******" AND password = MD5("' . $password . '")'; $r = $con->prepare($sql); $r->execute(); $result = $r->fetch(); $user = new user($result['iduser'], $result['login'], $result['password'], $result['name'], $result['privilege']); return $user; }
public function getLastPublishedTime($uid, $sn) { $db = new bd(); $statement = $db->prepare("SELECT * FROM manager_stats WHERE userid=? AND social_network=? ORDER BY time DESC LIMIT 1"); if ($statement->execute(array($uid, $sn))) { $fetch = $statement->fetchAll(); return $fetch[0]["time"]; } else { return false; } }
public function buscarAmigos2($id, $tipo = NULL, $busqueda = NULL) { $bd = new bd(); $querynatural = "SELECT ua.usuarios_id numero, seudonimo, CONCAT(nombre,' ', apellido) nombre, estados_id estado\n\t\t\t\t\t\t FROM usuarios_naturales un, usuarios_accesos ua, usuarios u \n\t\t\t\t\t\t WHERE u.id = un.usuarios_id AND u.id = ua.usuarios_id "; $queryjuridico = "SELECT ua.usuarios_id numero, seudonimo, razon_social nombre, estados_id estado \n\t\t\t\t\t\t FROM usuarios_juridicos uj, usuarios_accesos ua, usuarios u \n\t\t\t\t\t\t WHERE u.id = uj.usuarios_id AND u.id = ua.usuarios_id "; $estado = ""; $union = ""; $search = ""; if (!is_null($tipo)) { if ($tipo == "jur") { $querynatural = ""; } elseif ($tipo == "nat") { $queryjuridico = ""; } elseif ($tipo == "all") { $union = " UNION ALL "; } elseif (is_numeric($tipo)) { $estado = " AND estado = {$tipo} "; $union = " UNION ALL "; } } else { $union = " UNION ALL "; } if (!empty($busqueda)) { $search = " AND (nombre LIKE '%{$busqueda}%' OR seudonimo LIKE '%{$busqueda}%')"; } $statement = "SELECT numero, seudonimo, nombre, estado \n\t\t\t\t\t FROM ({$querynatural}\n\t\t\t\t\t\t {$union}\n\t\t\t\t\t\t {$queryjuridico}) tabla, usuarios_amigos \n\t\t\t\t\t WHERE usuarios_id = numero {$estado} {$search} "; die($statement); try { $sql = $bd->prepare($statement); $sql->execute(array($id)); if ($sql->rowCount() > 0) { return $sql->fetchAll(); } else { return false; } } catch (PDOException $ex) { return $bd->showError($ex); } }
public function getLastPublishedTime($id, $sn) { $db = new bd(); $statement = $db->prepare("SELECT * FROM manager_stats WHERE userid=:uid AND sn=':sn' ORDER BY time DESC LIMIT 1"); $statement->bindParam(':uid', $uid); $statement->bindParam(':sn', $sn); $statement->execute(); $fetch = $statement->fetchAll(); return $fetch[0]["time"]; }