本文整理汇总了PHP中DatabaseConnection::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::getConnection方法的具体用法?PHP DatabaseConnection::getConnection怎么用?PHP DatabaseConnection::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::getConnection方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePhoto
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());
}
}
示例2: createHomePageCustomizationArea
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();
}
}
示例3: authenticate
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;
}
示例4: generateUniqueLink
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;
}
}
示例5: getAll
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();
}
}
示例6: insert
/**
* 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();
}
示例7: existsByEmail
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());
}
}
示例8: array_push
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";
?>
示例9: existsByName
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());
}
}
示例10: insert
/**
* 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();
}
示例11: insert
/**
* 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();
}
示例12: addUser
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());
}
}