setFetchMode() public method

Sets the fetch mode.
public setFetchMode ( integer $fetchMode ) : void
$fetchMode integer
return void
Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
Arquivo: Db.php Projeto: moxi9/unity
 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);
     }
 }
Exemplo n.º 3
0
 /**
  * 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;
         }
     }
 }
Exemplo n.º 4
0
 public function __construct(Connection $connection)
 {
     $this->connection = $connection;
     $this->connection->setFetchMode(\PDO::FETCH_OBJ);
 }