本文整理汇总了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);
}