本文整理汇总了PHP中DBManager::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::getConnection方法的具体用法?PHP DBManager::getConnection怎么用?PHP DBManager::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::getConnection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
$this->pdo = DBManager::getConnection();
if (!$this->pdo instanceof DBMySQL) {
$this->markTestSkipped('Primary connection is not an instance of DBMySQL');
}
return parent::setUp();
}
示例2: testValidateOperator
function testValidateOperator()
{
$c = new Condition();
$c->add('foo', 'bar', 'SQL injection!');
$this->setExpectedException('InvalidArgumentException');
$stmnt = $c->getQueryStatement();
$stmnt->setConnection(DBManager::getConnection());
}
示例3: testGetConnectionNoArgument
/**
* @covers DBManager::getConnection
*/
public function testGetConnectionNoArgument()
{
$connection = DBManager::getConnection();
$this->assertInstanceOf('DABLPDO', $connection);
$connections = DBManager::getConnections();
// verify that $connection is the first connection
$this->assertEquals(array_shift($connections), $connection);
}
示例4: getQuery
/**
* Builds and returns the query string
*
* @param mixed $conn Database connection to use
* @return QueryStatement
*/
function getQuery(PDO $conn = null)
{
if (null === $conn && class_exists('DBManager')) {
$conn = DBManager::getConnection();
}
// the QueryStatement for the Query
$stmnt = new QueryStatement($conn);
// the string $statement will use
$qry_s = '';
$action = $this->_action;
switch ($action) {
default:
case self::ACTION_COUNT:
case self::ACTION_SELECT:
$columns_stmnt = $this->getColumnsClause($conn);
$stmnt->addIdentifiers($columns_stmnt->identifiers);
$stmnt->addParams($columns_stmnt->params);
$qry_s .= 'SELECT ' . $columns_stmnt->string . "\nFROM ";
break;
case self::ACTION_DELETE:
$qry_s .= "DELETE\nFROM ";
break;
case self::ACTION_UPDATE:
$qry_s .= "UPDATE\n";
break;
}
$table_stmnt = $this->getTablesClause($conn);
$stmnt->addIdentifiers($table_stmnt->identifiers);
$stmnt->addParams($table_stmnt->params);
$qry_s .= $table_stmnt->string;
if ($this->_joins) {
foreach ($this->_joins as $join) {
$join_stmnt = $join->getQueryStatement($conn);
$qry_s .= "\n\t" . $join_stmnt->string;
$stmnt->addParams($join_stmnt->params);
$stmnt->addIdentifiers($join_stmnt->identifiers);
}
}
if (self::ACTION_UPDATE === $action) {
if (empty($this->_updateColumnValues)) {
throw new RuntimeException('Unable to build UPDATE query without update column values');
}
$column_updates = array();
foreach ($this->_updateColumnValues as $column_name => &$column_value) {
$column_updates[] = QueryStatement::IDENTIFIER . '=' . QueryStatement::PARAM;
$stmnt->addIdentifier($column_name);
$stmnt->addParam($column_value);
}
$qry_s .= "\nSET " . implode(',', $column_updates);
}
$where_stmnt = $this->getWhereClause();
if (null !== $where_stmnt && $where_stmnt->string !== '') {
$qry_s .= "\nWHERE " . $where_stmnt->string;
$stmnt->addParams($where_stmnt->params);
$stmnt->addIdentifiers($where_stmnt->identifiers);
}
if ($this->_groups) {
$clause = $this->getGroupByClause();
$stmnt->addIdentifiers($clause->identifiers);
$stmnt->addParams($clause->params);
$qry_s .= $clause->string;
}
if (null !== $this->getHaving()) {
$having_stmnt = $this->getHaving()->getQueryStatement();
if (null !== $having_stmnt) {
$qry_s .= "\nHAVING " . $having_stmnt->string;
$stmnt->addParams($having_stmnt->params);
$stmnt->addIdentifiers($having_stmnt->identifiers);
}
}
if ($action !== self::ACTION_COUNT && $this->_orders) {
$clause = $this->getOrderByClause();
$stmnt->addIdentifiers($clause->identifiers);
$stmnt->addParams($clause->params);
$qry_s .= $clause->string;
}
if (null !== $this->_limit) {
if ($conn) {
if (class_exists('DBMSSQL') && $conn instanceof DBMSSQL) {
$qry_s = QueryStatement::embedIdentifiers($qry_s, $stmnt->getIdentifiers(), $conn);
$stmnt->setIdentifiers(array());
}
$conn->applyLimit($qry_s, $this->_offset, $this->_limit);
} else {
$qry_s .= "\nLIMIT " . ($this->_offset ? $this->_offset . ', ' : '') . $this->_limit;
}
}
if (self::ACTION_COUNT === $action && $this->needsComplexCount()) {
$qry_s = "SELECT count(0)\nFROM ({$qry_s}) a";
}
$stmnt->string = $qry_s;
return $stmnt;
}
示例5: getConnection
static function getConnection()
{
return DBManager::getConnection();
}
示例6: getBaseModel
/**
* Generates a string with the contents of the Base class
* @param string $table_name
* @param string $class_name
* @param array $options
* @return string
*/
function getBaseModel($table_name)
{
$class_name = $this->getModelName($table_name);
$options = $this->options;
//Gather all the information about the table's columns from the database
$PK = null;
$PKs = array();
$fields = $this->getColumns($table_name);
$conn = DBManager::getConnection($this->getConnectionName());
$auto_increment = false;
foreach ($fields as $field) {
if ($field->isPrimaryKey()) {
$PKs[] = $field->getName();
if ($field->isAutoIncrement()) {
$auto_increment = true;
}
}
}
if (count($PKs) == 1) {
$PK = $PKs[0];
} else {
$auto_increment = false;
}
ob_start();
require dirname(__FILE__) . $this->getBaseModelTemplate();
return ob_get_clean();
}
示例7: DBManager
<?php
include 'DBManager.php';
echo 'Creating DBMan <br>';
$dbm = new DBManager();
echo 'Calling getConnection() <br>';
$db = $dbm->getConnection();
echo 'Calling addUser() <br>';
$test1 = $dbm->addUser($db, "Best", "First", 23, 23) . "<br>";
echo 'Calling remUser() <br>';
//$dbm->remUser($db,"Best");
echo 'Calling findUser() <br>';
//$dbm->findUser($db,"Best");
echo 'Calling addRequest() <br>';
//var_dump($dbm->addRequest($db,"test","11","11"));
echo 'End <br>';
//$dbm->getFree($db);
var_dump($dbm->getGPS($db, "Best"));
$dbm->acceptDelivery($db, "557441c424c1d2a0008b4568", "Best");
echo 'End2';
示例8: testPropelJoinWithDatabasePrefix
function testPropelJoinWithDatabasePrefix()
{
$join = QueryJoin::create('db.foo.bar_id', 'foo2.bar_id')->setAlias('f');
$this->assertEquals((string) $join->getQueryStatement(DBManager::getConnection()), 'JOIN `foo2` AS f ON (`db`.`foo`.`bar_id` = `foo2`.`bar_id`)');
}
示例9: DBManager
<?php
header('Access-Control-Allow-Origin: *');
include 'DBManager.php';
$actionID = $_GET["actID"];
$dbman = new DBManager();
$conn = $dbman->getConnection();
switch ($actionID) {
case "adduser":
$login = $_GET["login"];
$pwd = $_GET["pwd"];
$lat = $_GET["lat"];
$lon = $_GET["lon"];
echo $dbman->addUser($conn, $login, $pwd, $lat, $lon);
break;
case "remuser":
$login = $_GET["login"];
echo $dbman->remUser($conn, $login);
break;
case "addrequest":
$login = $_GET["login"];
$price = $_GET["price"];
$reward = $_GET["reward"];
$itemlist = $_GET["itemlist"];
echo $dbman->addRequest($conn, $login, $price, $reward, $itemlist);
break;
case "remrequest":
$id = $_GET["id"];
echo $dbman->remRequest($conn, $id);
break;
case "getrequest":