本文整理汇总了PHP中Database::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::disconnect方法的具体用法?PHP Database::disconnect怎么用?PHP Database::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_comment
public static function update_comment()
{
$sql_query = "UPDATE `comments` SET `comment` = 'This is a Test Mannnnn hehheeh' WHERE `id` = '2'";
$pdo = Database::connect();
$pdo->query($sql_query);
Database::disconnect();
}
示例2: frameworkDir
function __construct($commitId = NULL)
{
$framework = frameworkDir();
/* Get the directory of the framework */
require_once $framework . '/class/Database.class.php';
$link = new Database();
$link->connect();
/* Connect */
if (!is_null($commitId)) {
/* Get data */
$sql = 'SELECT * FROM commits WHERE commitId = %1 ';
$result = $link->query($sql, $commitId);
$data = mysql_fetch_object($result);
/* Set variables */
$this->_commitId = $commitId;
$this->_repoId = $data->repoId;
$this->_commitVal = $data->commitVal;
$this->_commitMessage = $data->commitMessage;
$this->_commitDateTime = $data->commitDateTime;
$this->_commitAuthor = $data->commitAuthor;
} else {
$this->_commitId = -1;
$this->_repoId = -1;
$this->_commitVal = '';
$this->_commitMessage = '';
$this->_commitDateTime = '';
}
/* Close link */
$link->disconnect();
}
示例3: increaseSearchDb
public static function increaseSearchDb()
{
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE metricas SET busquedas = busquedas + 1";
$q = $pdo->prepare($sql);
$q->execute();
Database::disconnect();
}
示例4: authenticate
function authenticate($username, $password)
{
require_once 'lib/functions.lib.php';
$framework = frameworkDir();
require_once $framework . '/class/Database.class.php';
$link = new Database();
$link->connect();
$sql = 'SELECT * FROM users WHERE username = %1 AND password = %2 ';
$result = $link->query($sql, $_POST['username'], md5($_POST['password']));
if (mysql_num_rows($result) == 1) {
$data = mysql_fetch_object($result);
$link->disconnect();
return $data;
} else {
$link->disconnect();
return false;
}
}
示例5: delete
public function delete($id)
{
$db = new Database();
$db->connect();
$where = 'id=' . $id;
$result = $db->delete(static::$tableName, $where);
$returnValue;
if ($result) {
$returnValue = TRUE;
} else {
$returnValue = FALSE;
}
$db->disconnect();
return $returnValue;
}
示例6: disconnect
public function disconnect()
{
try {
$status = TRUE;
if (is_resource($this->_connection)) {
if ($status = mysql_close($this->_connection)) {
$this->_connection = NULL;
parent::disconnect();
}
}
} catch (Exception $e) {
$status = !is_resource($this->_connection);
}
return $status;
}
示例7: read
public static function read($id)
{
$sql = "SELECT * FROM users WHERE id=:id";
try {
$db = Database::connect();
$stmt = $db->prepare($sql);
$stmt->bindParam(":id", $id);
$stmt->execute();
$user = $stmt->fetchObject();
return $user;
Database::disconnect();
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
}
}
示例8: showAllUsers
public function showAllUsers()
{
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$statement = $pdo->prepare("SELECT id,username,email,administrator,blocked FROM users");
$statement->execute();
} catch (Exception $e) {
Database::disconnect();
return $e->getMessage();
}
$data = $statement->fetchAll(PDO::FETCH_ASSOC);
Database::disconnect();
echo json_encode($data);
}
示例9: readAll
public static function readAll()
{
$sql = "SELECT * FROM suscriptor ORDER BY id";
try {
$db = Database::connect();
$stmt = $db->query($sql);
$stmt->setFetchMode(PDO::FETCH_OBJ);
while ($CurrentUser = $stmt->fetch()) {
echo '<p><b> Nombre: </b>' . $CurrentUser->nombre . '<b> Correo: </b>' . $CurrentUser->correo . '</p>';
}
Database::disconnect();
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
}
}
示例10: updateLoginCounter
public function updateLoginCounter($ip, $counter)
{
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$counter = (int) $counter + 1;
$statement = $pdo->prepare("UPDATE login_attempts SET login_counter=:counter WHERE ip=:ip");
try {
$statement->execute(array("ip" => $ip, "counter" => $counter));
//test
Database::disconnect();
return $counter;
} catch (Exception $e) {
Database::disconnect();
return $e->getMessage();
}
Database::disconnect();
}
示例11: create
public static function create($Username, $Contrasena)
{
$sql = 'INSERT INTO News (Username, Contrasena) VALUES (:Username,:Contrasena)';
try {
$db = Database::connect();
$stmt = $db->prepare($sql);
$stmt->bindParam(':Username', $Username);
$stmt->bindParam(':Contrasena', $Contrasena);
$stmt->execute();
Database::disconnect();
echo "<script>alert(':D'); location.href='index.php'</script>";
return true;
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
return false;
}
}
示例12: create
public static function create($CORREO, $CONTRASENA)
{
$sql = 'INSERT INTO TABLAWEB (CORREO, CONTRASENA) VALUES (:CORREO,:CONTRASENA)';
try {
$db = Database::connect();
$stmt = $db->prepare($sql);
$stmt->bindParam(':CORREO', $CORREO);
$stmt->bindParam(':CONTRASENA', $CONTRASENA);
$stmt->execute();
Database::disconnect();
echo "<script>alert('EL REGISTRO FUE EXITOSO'); location.href='index.php'</script>";
return true;
} catch (PDOException $e) {
echo 'Error: ' . $e->getMessage();
return false;
}
}
示例13: fillindevice
function fillindevice()
{
global $lang, $error, $devid, $devtype, $acreg, $accn, $actype, $notrack, $noident, $twig;
$catarray = array(1 => 'Gliders/motoGliders', 2 => 'Planes', 3 => 'Ultralights', 4 => 'Helicoters', 5 => 'Drones/UAV', 6 => 'Others');
$dtypc = array('', '', '');
$dtypc[$devtype] = 'checked';
$aircraft = array();
$dbh = Database::connect();
$result = $dbh->query('SELECT * FROM aircrafts ORDER BY ac_cat,ac_type');
foreach ($result as $row) {
$selected = $row['ac_id'] == $actype ? 'selected' : '';
$aircraft[$row['ac_cat']][] = array('id' => $row['ac_id'], 'type' => $row['ac_type'], 'selected' => $selected);
}
Database::disconnect();
$template_vars = array('aircrafts' => $aircraft, 'lang' => $lang, 'error' => $error, 'dtypc' => $dtypc, 'catarray' => $catarray, 'cnotrack' => $notrack ? 'checked' : '', 'cnoident' => $noident ? 'checked' : '', 'devid' => $devid, 'acreg' => $acreg, 'accn' => $accn);
echo $twig->render('fillindevice.html.twig', $template_vars);
}
示例14: get_question_details
public function get_question_details($qid)
{
$result = array();
$db = new Database();
if ($db->connect()) {
if ($db->select('questions', 'q_id,c_id,q_name,q_tag,q_hint,q_points', NULL, 'q_id=' . $qid)) {
$dbResult = $db->getResult();
foreach ($dbResult as $out) {
$q = new question();
$q->set_question_information($out['q_id'], $out['c_id'], $out['q_name'], $out['q_tag'], $out['q_hint'], $out['q_points']);
array_push($result, $q);
}
}
$db->disconnect();
}
return $result;
}
示例15: get_ScreenName
function get_ScreenName($find)
{
$pdo = Database::connect();
$sql = "SELECT * FROM userimagedetails";
$rows = $pdo->query($sql);
global $nameArray;
foreach ($rows as $row) {
$nameArray = array($row['userName']);
}
Database::disconnect();
//get a return
foreach ($nameArray as $name) {
if ($name == $find) {
return $name;
break;
}
}
}