예제 #1
0
 function testPgSQL()
 {
     $oDbh = OA_DB::singleton();
     if ($oDbh->dbsyntax == 'pgsql') {
         $oDbc = OA_DB_Charset::factory($oDbh);
         $this->assertTrue($oDbc);
         $this->assertTrue($oDbc->oDbh);
         $this->assertEqual($oDbc->getDatabaseCharset(), 'UTF8');
         $this->assertEqual($oDbc->getClientCharset(), 'UTF8');
         $aCharsets = array('LATIN1', 'UTF8', 'SJIS');
         foreach ($aCharsets as $charset) {
             $this->assertTrue($oDbc->setClientCharset($charset));
             $this->assertEqual($oDbc->getClientCharset(), $charset);
         }
     }
 }
예제 #2
0
 /**
  * A method to set the client encoding.
  *
  * @param MDB2_Driver_common $oDbh
  * @return mixed True on succes, PEAR_Error otherwise
  */
 static function setCharset($oDbh)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     $oDbc = OA_DB_Charset::factory($oDbh);
     if (!empty($aConf['databaseCharset']['checkComplete'])) {
         $charset = $aConf['databaseCharset']['clientCharset'];
     } else {
         $charset = $oDbc->getConfigurationValue();
     }
     return $oDbc->setClientCharset($charset);
 }
예제 #3
0
 /**
  * add any needed database parameter to the config array
  *
  * @param array $aConfig
  *
  * @return array
  */
 function initDatabaseParameters($aConfig)
 {
     // Check if we need to ensure to enable MySQL 4 compatibility
     if (strcasecmp($aConfig['database']['type'], 'mysql') === 0) {
         $result = $this->oDbh->exec("SET SESSION sql_mode='MYSQL40'");
         $aConfig['database']['mysql4_compatibility'] = !PEAR::isError($result);
     }
     // Set charset information
     $oDbc =& OA_DB_Charset::factory($this->oDbh);
     $charset = $oDbc->getConfigurationValue();
     $aConfig['databaseCharset'] = array('checkComplete' => true, 'clientCharset' => $charset ? $charset : '');
     return $aConfig;
 }