本文整理汇总了PHP中PDOConnection::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOConnection::connect方法的具体用法?PHP PDOConnection::connect怎么用?PHP PDOConnection::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOConnection
的用法示例。
在下文中一共展示了PDOConnection::connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* constructor
**/
public function __construct()
{
$this->host = db_host();
$this->dbname = db_name();
$this->user = db_user();
$this->pass = db_psw();
$this->path = db_path();
switch (db_type()) {
case "mysql":
$dsn = 'mysql:host=' . $this->host . ";port=" . db_port() . ';dbname=' . $this->dbname;
break;
case "sqlite":
$dsn = 'sqlite:' . $this->path . ';';
break;
case "postgresql":
$dsn = 'pgsql:host=' . $this->host . ";port=" . db_port() . ';dbname=' . $this->dbname;
break;
default:
$dsn = 'mysql:host=' . $this->host . ";port=" . db_port() . ';dbname=' . $this->dbname;
}
$connection = new PDOConnection($dsn, $this->user, $this->pass, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY, PDO::ATTR_TIMEOUT => 60 * 60 * 60 * 60, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_PERSISTENT => false]);
$connection->connect();
$this->dbh = new Database($connection);
}
示例2: PDOConnection
<script language="javascript" src="../include/function.script.js"></script>
</head>
<body>
<center>
<div id="admin-head">
<img src="images/admin_ico.png" hspace="10" vspace="2" border="0" align="left">
<h1>Administrator</h1>
<strong><?php
echo $default->get('title');
?>
</strong>
</div>
<?php
$admin = new PDOConnection();
$admin->connect();
if (isset($_POST['submit'])) {
$login = new Login();
if ($_POST['username'] != _ADMIN_USERNAME || $_POST['password'] != _ADMIN_PASSWORD) {
$login->adminCheack($_POST['username'], $_POST['password']);
} else {
echo '<div id="error">' . _ADMIN_ERROR_1 . '</div>';
}
}
if (!$default->get('DVGID')) {
?>
<div id="admin-login">
<h5><?php
echo _ADMIN_HEAD;
?>
</h5>