本文整理汇总了PHP中DBConnector::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnector::connect方法的具体用法?PHP DBConnector::connect怎么用?PHP DBConnector::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnector
的用法示例。
在下文中一共展示了DBConnector::connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJSONFromDB
public function getJSONFromDB()
{
$db = new DBConnector();
$sql = "SELECT s.spieltag, s.datum, sp.datum, sp.stadion, sp.heim, sp.gast, sp.tore_heim, sp.tore_gast FROM spieltag s, spiele sp WHERE s.spieltag = sp.spieltag_id";
$mysql = $db->connect();
$result = $mysql->query($sql);
$json = array();
while ($row = $result->fetch_assoc()) {
$json[] = $row;
}
return $json;
}
示例2: connect
/**
* Instruct the database to generate a live connection
*
* @param array $parameters An map of parameters, which should include:
* - server: The server, eg, localhost
* - username: The username to log on with
* - password: The password to log on with
* - database: The database to connect to
* - charset: The character set to use. Defaults to utf8
* - timezone: (optional) The timezone offset. For example: +12:00, "Pacific/Auckland", or "SYSTEM"
* - driver: (optional) Driver name
*/
public function connect($parameters)
{
// Ensure that driver is available (required by PDO)
if (empty($parameters['driver'])) {
$parameters['driver'] = $this->getDatabaseServer();
}
// Notify connector of parameters
$this->connector->connect($parameters);
// SS_Database subclass maintains responsibility for selecting database
// once connected in order to correctly handle schema queries about
// existence of database, error handling at the correct level, etc
if (!empty($parameters['database'])) {
$this->selectDatabase($parameters['database'], false, false);
}
}
示例3: Collection
<?php
/**
* Created by PhpStorm.
* User: Denis
* Date: 30.11.2015
* Time: 12:44
*/
$collection = new Collection();
$connection = new DBConnector();
$db = $connection->connect();
$sql = mysql_query("SELECT * FROM author", $db);
var_dump($sql);
$author_1 = new SimpleAuthor();