本文整理匯總了PHP中Doctrine\DBAL\Connection::setFetchMode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::setFetchMode方法的具體用法?PHP Connection::setFetchMode怎麽用?PHP Connection::setFetchMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::setFetchMode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setupConfigurationDbal
/**
* setup configuration for Doctrine Dbal.
*
* @param array $db_config array config for override the default configuration.
*/
public function setupConfigurationDbal(array $db_config = [])
{
$dbal_config = new Configuration();
if (empty($db_config)) {
//setup connection configuration.
$config = new SystemConfig();
$config->load('db');
$db_params = $config->get('ALL', 'db');
unset($config, $db_params['table_prefix']);
} else {
$db_params = $db_config;
unset($db_params['table_prefix']);
}
$dbal_config->setSQLLogger(new \System\Libraries\Db\Logger());
try {
$this->Conn = DriverManager::getConnection($db_params, $dbal_config);
$this->Conn->connect();
} catch (\Doctrine\DBAL\DBALException $e) {
http_response_code(500);
echo $e->getMessage();
exit;
}
$this->Conn->setFetchMode(\PDO::FETCH_OBJ);
unset($dbal_config, $db_params);
}
示例2: connect
public function connect()
{
if ($this->connection === null) {
$connection_params = array('dbname' => config()->db_name(), 'user' => config()->db_user(), 'password' => config()->db_pass(), 'host' => config()->db_host(), 'driver' => 'pdo_mysql');
$this->connection = \Doctrine\DBAL\DriverManager::getConnection($connection_params, new \Doctrine\DBAL\Configuration());
$this->connection->setFetchMode(\PDO::FETCH_OBJ);
}
}
示例3: __construct
/**
* Contructor
*
* @var string $dsn The connection string
* @var string $tablePrefix Table prefix
*/
public function __construct($dsn, $tablePrefix = null)
{
$this->con = \Doctrine\DBAL\DriverManager::getConnection(array('url' => $dsn));
$this->con->setFetchMode(\PDO::FETCH_ASSOC);
if (!empty($tablePrefix)) {
foreach ($this->tables as $tableName) {
$this->tables[$tableName] = rtrim($tablePrefix, '_') . '_' . $tableName;
}
}
}
示例4: __construct
public function __construct(Connection $connection)
{
$this->connection = $connection;
$this->connection->setFetchMode(\PDO::FETCH_OBJ);
}