public static function updatePhoto($code, $name) { try { $c = DatabaseConnection::getConnection(); $c->query("update tbl_portfolio set image='{$name}' where code={$code}"); $c = null; } catch (Exception $exception) { throw new DAOException("getPortfolioByCode() " . $exception->getMessage()); } }
function createHomePageCustomizationArea() { try { $c = DatabaseConnection::getConnection(); $rs = $c->query("select * from tbl_homedata"); echo '<form action="" method="GET" >'; foreach ($rs as $row) { echo "<label>" . $row["propertyLabel"] . "</label>"; echo '<input type="text" class="form-control" name="' . $row["propertyName"] . '" value="' . $row["propertyValue"] . '" required >'; echo "<br/>"; } echo '<button type="submit" class="btn btn-success btn-lg myButton pull-right">Save</button>'; echo "<br/>"; echo "</form>"; $rs = null; $c = null; } catch (Exception $exception) { echo $exception->getMessage(); } }
public function authenticate($admin) { $valid = false; $c = DatabaseConnection::getConnection(); try { $ps = $c->prepare("select name from administrator where username=? and password=?"); $ps->bindParam(1, $admin->username); $ps->bindParam(2, $admin->password); $ps->execute(); $row = $ps->fetch(PDO::FETCH_ASSOC); if ($row) { $admin->name = $row["name"]; $valid = true; } } catch (PDOException $pe) { $valid = false; } catch (Exception $e) { $valid = false; } $c = null; return $valid; }
function generateUniqueLink() { $suffix = generateRandomString(); try { $c = DatabaseConnection::getConnection(); $ps = $c->prepare("select * from tbl_url_mapping where link_suffix = ?"); $ps->bindParam(1, $suffix); $ps->execute(); $row = null; $row = $ps->fetch(PDO::FETCH_ASSOC); if ($row) { $ps = null; $c = null; return null; } else { $ps = null; $c = null; return $suffix; } } catch (Exception $exception) { return null; } }
public function getAll() { $c = DatabaseConnection::getConnection(); try { $rs = $c->query("select username,employee_id,name,is_blocked from operator order by name"); $operators = []; $x = 0; foreach ($rs as $row) { $operator = new Operator(); $operator->username = trim($row["username"]); $operator->employeeId = trim($row["employee_id"]); $operator->name = trim($row["name"]); $operator->isBlocked = $row["is_blocked"]; $operators[$x] = $operator; $x++; } $c = null; return $operators; } catch (PDOException $pe) { print $pe->getMessage(); } catch (Exception $e) { print $e->getMessage(); } }
/** * Método implementado da interface * @see Model#insert * @return boolean */ public static function insert($values) { $pdo = DatabaseConnection::getConnection(); $sth = $pdo->prepare("INSERT INTO images (title, description, file_name, file_content_type, file_size) VALUES (:title, :description, :file_name, :file_content_type, :file_size)"); $sth->bindParam(':title', $values['title'], PDO::PARAM_STR, 150); $sth->bindParam(':description', $values['description'], PDO::PARAM_STR); $sth->bindParam(':file_name', $values['file_name'], PDO::PARAM_STR); $sth->bindParam(':file_content_type', $values['file_content_type'], PDO::PARAM_STR); $sth->bindParam(':file_size', $values['file_size'], PDO::PARAM_INT); return $sth->execute(); }
public function existsByEmail($memberEmail) { try { $c = DatabaseConnection::getConnection(); $rs = $c->query("select * from tbl_member where email='" . $memberEmail . "'"); $x = 0; foreach ($rs as $row) { $x++; } $rs = null; $ps = null; $c = null; if ($x > 0) { return true; } return false; } catch (Exception $exception) { throw new DAOException("MemberDAO : existsByEmail : " . $exception->getMessage()); } }
array_push($ar, 'facebookLink'); array_push($ar, 'googlePlusLink'); array_push($ar, 'linkedInLink'); array_push($ar, 'twitterLink'); try { $x = 0; $valid = TRUE; while ($x < sizeof($ar)) { if (!isset($_GET[$ar[$x]])) { $valid = FALSE; break; } $x++; } if ($valid) { $c = DatabaseConnection::getConnection(); $x = 0; while ($x < sizeof($ar)) { $ps = $c->prepare("update tbl_homedata set propertyValue=? where propertyName=?"); $ps->bindParam(1, $_GET[$ar[$x]]); $ps->bindParam(2, $ar[$x]); $ps->execute(); $x++; } $message = "<h3 style='margin-bottom:30px;margin-left:100px;'>Details Updated</h3>"; } } catch (Exception $exception) { echo $exception->getMessage(); } include "partials/header.php"; ?>
public function existsByName($roleName) { try { $c = DatabaseConnection::getConnection(); $rs = $c->query("select * from tbl_role where name= '" . $roleName . "'"); $x = 0; foreach ($rs as $row) { $x++; } $rs = null; $ps = null; $c = null; if ($x > 0) { return true; } return false; } catch (Exception $exception) { throw new DAOException("RoleDAO : existsByName : " . $exception->getMessage()); } }
/** * Método implementado da interface * @see Model#insert * @return boolean */ public static function insert($values) { $pdo = DatabaseConnection::getConnection(); $sth = $pdo->prepare("INSERT INTO image_sizes (image_id, image_type_id, file_name, file_content_type, file_size) VALUES (:image_id, :image_type_id, :file_name, :file_content_type, :file_size)"); $sth->bindParam(':image_id', $values['image']->getId(), PDO::PARAM_INT); $sth->bindParam(':image_type_id', $values['image_type']->getId(), PDO::PARAM_INT); $sth->bindParam(':file_name', $values['file_name'], PDO::PARAM_STR, 255); $sth->bindParam(':file_content_type', $values['file_content_type'], PDO::PARAM_STR, 255); $sth->bindParam(':file_size', $values['file_size'], PDO::PARAM_INT); return $sth->execute(); }
/** * Método implementado da interface * @see Model#insert * @return boolean */ public static function insert($values) { $pdo = DatabaseConnection::getConnection(); $sth = $pdo->prepare("INSERT INTO image_types (name, width, height) VALUES (:name, :width, :height)"); $sth->bindParam(':name', $values['name'], PDO::PARAM_STR, 150); $sth->bindParam(':width', $values['width']); $sth->bindParam(':height', $values['height']); return $sth->execute(); }
public static function addUser($user) { try { $c = DatabaseConnection::getConnection(); $password = md5($user->password); $valid = $c->query("insert into tbl_user (name ,username ,password) values ('{$user->name}','{$user->username}','{$password}')"); if ($valid == false) { throw new DAOException("cannot add user"); } } catch (Exception $exception) { throw new DAOException("checkUsernameAvailable() -> " . $exception->getMessage()); } }