本文整理汇总了PHP中Connection::getDriver方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getDriver方法的具体用法?PHP Connection::getDriver怎么用?PHP Connection::getDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::getDriver方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @return null
*/
public function setUp()
{
$this->runDbStartupTask();
$connector = DbRegistry::getConnector('af-tester');
$this->conn = $connector->getConnection();
$this->conn->connect();
$driver = $this->conn->getDriver();
$this->stmtDriver = $driver->stmt_init();
$this->stmt = new PreparedStmt($this->stmtDriver);
}
示例2: testInitialStatus
/**
* @return null
*/
public function testInitialStatus()
{
$this->assertTrue($this->conn->isDriver());
$this->assertInstanceOf('mysqli', $this->conn->getDriver());
$this->assertEquals('initialized', $this->conn->getStatus());
$this->assertFalse($this->conn->isError());
$this->assertFalse($this->conn->isConnected());
$this->assertEquals(0, $this->conn->getErrorCode());
$this->assertNull($this->conn->getErrorText());
}
示例3: __construct
/**
* @param string SQL command or table or view name, as data source
* @param Connection connection
*/
public function __construct($sql, Connection $connection)
{
if (strpbrk($sql, " \t\r\n") === FALSE) {
$this->sql = $connection->getDriver()->escapeIdentifier($sql);
// table name
} else {
$this->sql = '(' . $sql . ') t';
// SQL command
}
$this->connection = $connection;
}
示例4: Connection
fprintf($fd, "<table border=\"1\">\n\t\t<tr>\n\t\t\t<th>Test suite for PPA</th>\n\t\t</tr>\n");
fclose($fd);
/* Loop on the servers given in the conf/config.inc.conf file */
foreach ($conf['servers'] as $server) {
// Is this server in our list of configured servers?
if (!in_array($server['desc'], $test_servers)) {
continue;
}
/* connect to the server to get its version
* and test its feature along the tests */
$_c = new Connection($server['host'], $server['port'], $server['sslmode'], $super_user[$server['desc']], $super_pass[$server['desc']], $server['defaultdb']);
$_type = $data = null;
if (!$_c->conn->isConnected()) {
die("Connection to {$server['desc']} failed !\n");
} else {
if (($_type = $_c->getDriver($platform)) === null) {
die(printf($lang['strpostgresqlversionnotsupported'], $postgresqlMinVer));
}
/* create the database handler we are going to use in the tests creator scripts */
include_once './classes/database/' . $_type . '.php';
$data = new $_type($_c->conn);
$data->platform = $_c->platform;
}
fprintf(STDERR, "Connected to %s...\n", $server['desc']);
if (!is_dir("{$test_static_dir}/{$server['desc']}")) {
mkdir("{$test_static_dir}/{$server['desc']}");
}
$fd = opendir($test_src_dir);
$files = array();
while ($file = readdir($fd)) {
if ($file != '.' && $file != '..') {
示例5: __construct
public function __construct(Connection $connection)
{
$this->connection = $connection;
$this->driver = $connection->getDriver();
$this->identifiers = new HashMap([$this, 'delimite']);
}
示例6: getDatabaseAccessor
/**
* Creates a database accessor
*/
function getDatabaseAccessor($database, $server_id = null)
{
global $lang, $conf, $misc, $_connection;
$server_info = $this->getServerInfo($server_id);
// Perform extra security checks if this config option is set
if ($conf['extra_login_security']) {
// Disallowed logins if extra_login_security is enabled.
// These must be lowercase.
$bad_usernames = array('pgsql', 'postgres', 'root', 'administrator');
$username = strtolower($server_info['username']);
if ($server_info['password'] == '' || in_array($username, $bad_usernames)) {
unset($_SESSION['webdbLogin'][$_REQUEST['server']]);
$msg = $lang['strlogindisallowed'];
include './login.php';
exit;
}
}
// Create the connection object and make the connection
$_connection = new Connection($server_info['host'], $server_info['port'], $server_info['sslmode'], $server_info['username'], $server_info['password'], $database);
// Get the name of the database driver we need to use.
// The description of the server is returned in $platform.
$_type = $_connection->getDriver($platform);
if ($_type === null) {
printf($lang['strpostgresqlversionnotsupported'], $postgresqlMinVer);
exit;
}
$this->setServerInfo('platform', $platform, $server_id);
$this->setServerInfo('pgVersion', $_connection->conn->pgVersion, $server_id);
// Create a database wrapper class for easy manipulation of the
// connection.
include_once './classes/database/' . $_type . '.php';
$data = new $_type($_connection->conn);
$data->platform = $_connection->platform;
/* we work on UTF-8 only encoding */
$data->execute("SET client_encoding TO 'UTF-8'");
return $data;
}
示例7: loadFromFile
/**
* Import SQL dump from file.
* @return int count of sql commands
*/
public static function loadFromFile(Connection $connection, $file)
{
@set_time_limit(0);
// intentionally @
$handle = @fopen($file, 'r');
// intentionally @
if (!$handle) {
throw new \RuntimeException("Cannot open file '{$file}'.");
}
$count = 0;
$delimiter = ';';
$sql = '';
$driver = $connection->getDriver();
while (!feof($handle)) {
$s = rtrim(fgets($handle));
if (substr($s, 0, 10) === 'DELIMITER ') {
$delimiter = substr($s, 10);
} elseif (substr($s, -strlen($delimiter)) === $delimiter) {
$sql .= substr($s, 0, -strlen($delimiter));
$driver->query($sql);
$sql = '';
$count++;
} else {
$sql .= $s . "\n";
}
}
if (trim($sql) !== '') {
$driver->query($sql);
$count++;
}
fclose($handle);
return $count;
}