function __construct() { require_once 'DB_Connect.php'; // connecting to database $db = new DBConnect(); $this->conn = $db->connect(); }
public function checkLogin($user, $pw) { $db = new DBConnect(); $mysql = $db->connect(); $sql = "SELECT * FROM user WHERE nickname = '" . $user . "' AND pw = '" . sha1($pw) . "'"; $result = $mysql->query($sql); if ($mysql->affected_rows == 1) { $row = $result->fetch_assoc(); $_SESSION['nickname'] = $row['nickname']; $_SESSION['firstname'] = $row['firstname']; $_SESSION['lastname'] = $row['lastname']; $_SESSION['email'] = $row['email']; $_SESSION['loggedin'] = true; $db->close(); return true; } $db->close(); return false; }
<?php require_once '../db.php'; $db = new DBConnect(); $con = $db->connect(); if (!is_null($con)) { $rawdata = file_get_contents('php://input'); $obj = json_decode($rawdata); if (isset($obj->id_payment)) { $query = sprintf("delete from payment where id = '%s'", $con->real_escape_string($obj->id_payment)); $result = $con->query($query); if ($result) { header("HTTP/1.1 200 OK"); } else { header("HTTP/1.1 500 Internal Server Error"); } } else { header("HTTP/1.1 500 Internal Server Error"); } } else { header("HTTP/1.1 500 Internal Server Error"); }
function __construct() { $data = array('host' => 'localhost', 'db' => 'test', 'user' => 'root', 'pwd' => ''); $this->_c = DBConnect::connect($data); }
public static final function _Connect(){ $db = new DBConnect(); $db->connect(self::PUBLIC_SERVER, self::PUBLIC_ENTRY, self::PUBLIC_PASS, self::PUBLIC_DATABASE); return $db; }
<?php // 데이터베이스에 레코드를 수정하는 페이지 include "dbConnect.php"; error_reporting(E_ALL); ini_set("display_errors", 1); $subject = $_POST["subject"]; // POST 변수로 제목 변수 받아옴 $content = $_POST["content"]; // POST 변수로 내용 변수 받아옴 $num = $_POST["num"]; // POST 변수로 번호 변수 받아옴 $ip = $_SERVER["REMOTE_ADDR"]; // 클라이언트 IP 받아옴 $db = new DBConnect(); $db->connect(); $query = "update dictionary set subject = '{$subject}', content = '{$content}', ip = '{$ip}', regdate = now() where num = {$num};"; // DB에서 레코드를 수정하기 위한 쿼리문 mysql_query($query); // 쿼리문 실행 $db->disconnect();
/** * * @global DBConnect $__conn * @return DBConnect */ public static function GetDefaultConnection() { static $__conn; require_once FCORE_FILE_DBCONNECT; if ($__conn == null) { $__conn = new DBConnect(self::$GLOBAL_LOGGER); } if (!$__conn->isConnected()) { $__conn->connect(self::$DB_DEFAULT_HOST, self::$DB_DEFAULT_USER, self::$DB_DEFAULT_PASS, self::$DB_DEFAULT_DB); } return $__conn; }