Prado\Data\TDbConnection::setUsername PHP Метод

setUsername() публичный Метод

public setUsername ( $value )
    public function setUsername($value)
    {
        $this->_username = $value;
    }

Usage Example

Пример #1
0
 /**
  * Creates the DB connection.
  * @param string the module ID for TDataSourceConfig
  * @return TDbConnection the created DB connection
  * @throws TConfigurationException if module ID is invalid or empty
  */
 protected function createDbConnection()
 {
     if ($this->_connID !== '') {
         $config = $this->getApplication()->getModule($this->_connID);
         if ($config instanceof TDataSourceConfig) {
             return $config->getDbConnection();
         } else {
             throw new TConfigurationException('dbcache_connectionid_invalid', $this->_connID);
         }
     } else {
         $db = new TDbConnection();
         if ($this->_connectionString !== '') {
             $db->setConnectionString($this->_connectionString);
             if ($this->_username !== '') {
                 $db->setUsername($this->_username);
             }
             if ($this->_password !== '') {
                 $db->setPassword($this->_password);
             }
         } else {
             // default to SQLite3 database
             $dbFile = $this->getApplication()->getRuntimePath() . '/sqlite3.cache';
             $db->setConnectionString('sqlite:' . $dbFile);
         }
         return $db;
     }
 }