quick_connect() 공개 메소드

******************************************************************** Short hand way to connect to mySQL database server and select a mySQL database at the same time
public quick_connect ( $dbuser = '', $dbpassword = '', $dbname = '', $dbhost = 'localhost', $dbport = '3306', $encoding = '' )
예제 #1
1
 public function setUp()
 {
     parent::setUp();
     // create app
     $config = $this->appConfig + array('base_url' => 'http://localhost/');
     $app = new \FelixOnline\Core\App($config);
     $dbuser = getenv('DB_USER') ? getenv('DB_USER') : 'root';
     $dbpass = getenv('DB_PASS') ? getenv('DB_PASS') : '';
     $db = new \ezSQL_mysqli();
     $db->quick_connect($dbuser, $dbpass, 'test_media_felix', 'localhost', 3306, 'utf8');
     $app['db'] = $db;
     $app['safesql'] = new \SafeSQL_MySQLi($db->dbh);
     $app['env'] = \FelixOnline\Core\Environment::mock();
     // Initialize Akismet
     $connector = new \Riv\Service\Akismet\Connector\Test();
     $app['akismet'] = new \Riv\Service\Akismet\Akismet($connector);
     // Initialize email
     $transport = \Swift_NullTransport::newInstance();
     $app['email'] = \Swift_Mailer::newInstance($transport);
     $session = $this->mock('FelixOnline\\Core\\Session')->getId(1)->start(1)->reset()->new();
     $this->reflect($session)->__set('session', array());
     $app['env']['session'] = $session;
     $cookies = $this->mock('FelixOnline\\Core\\Cookies')->set(true)->delete(true)->new();
     $this->reflect($cookies)->__set('cookies', array());
     $app['env']['cookies'] = $cookies;
     if ($this->setCurrentUser) {
         $app['currentuser'] = new \FelixOnline\Core\CurrentUser();
     }
     // Set empty cache so data isn't cached in tests
     $app['cache'] = new \Stash\Pool();
     $app->run();
     $this->app = $app;
 }
예제 #2
0
 public function createApp($config)
 {
     $app = new \FelixOnline\Core\App($config);
     $dbuser = getenv('DB_USER') ? getenv('DB_USER') : 'root';
     $dbpass = getenv('DB_PASS') ? getenv('DB_PASS') : '';
     $db = new \ezSQL_mysqli();
     $db->quick_connect($dbuser, $dbpass, 'test_media_felix', 'localhost', 3306, 'utf8');
     $app['db'] = $db;
     $app['safesql'] = new \SafeSQL_MySQLi($db->dbh);
     $app['env'] = \FelixOnline\Core\Environment::mock();
     $session = $this->mock('FelixOnline\\Core\\Session')->getId(1)->start(1)->reset()->new();
     $this->reflect($session)->__set('session', array());
     $app['env']['session'] = $session;
     $app->run();
     return $app;
 }