本文整理汇总了PHP中app\App::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP App::getConnection方法的具体用法?PHP App::getConnection怎么用?PHP App::getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\App
的用法示例。
在下文中一共展示了App::getConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* login process
*/
public static function login()
{
// form validation
if (!filter_input(INPUT_POST, "form_token") || Form::isFormTokenValid(filter_input(INPUT_POST, "form_token"))) {
View::setMessageFlash("danger", "Form tidak valid");
return FALSE;
}
if (!filter_input(INPUT_POST, "username") || !filter_input(INPUT_POST, "password")) {
View::setMessageFlash("danger", "Masukkan Username dan Password");
return FALSE;
}
$username = filter_input(INPUT_POST, "username", FILTER_SANITIZE_STRING);
$password = md5(filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING));
$mysqli = App::getConnection(true);
$sql = "SELECT user_id FROM users WHERE username='{$username}' AND password='{$password}'";
if (!($query = $mysqli->query($sql))) {
View::setMessageFlash("danger", $mysqli->error);
return FALSE;
}
if ($query->num_rows == 0) {
View::setMessageFlash("danger", "Username dan Password Salah");
return FALSE;
}
$row = $query->fetch_row();
$_SESSION['user_id'] = $row[0];
return TRUE;
}
示例2: __construct
public function __construct($id)
{
$mysqli = App::getConnection(true);
$sql = "SELECT * FROM " . $this->table . " WHERE " . $this->key . " = '" . $id . "'";
if (!($query = $mysqli->query($sql))) {
return;
}
$this->data = $query->fetch_assoc();
}
示例3: update
public function update()
{
$mysqli = App::getConnection(true);
$sql = "UPDATE " . $this->table . " SET ";
$sql .= "name='" . $this->data['name'] . "', ";
$sql .= "phone='" . $this->data['phone'] . "', ";
$sql .= "address='" . $this->data['address'] . "' ";
$sql .= "WHERE " . $this->key . "='" . $this->data[$this->key] . "' ";
if (!($query = $mysqli->query($sql))) {
return FALSE;
}
return TRUE;
}