コード例 #1
0
ファイル: ImportStat.php プロジェクト: caiofior/cercaziende
  public function import()
  {
      foreach (glob($this->db->config->logBaseDir . '/stat_oper*') as $statFile) {
          $statHandler = fopen($statFile, 'r');
          echo $statFile . PHP_EOL;
          $rawData = fgetcsv($statHandler, 100, ';');
          $data = $this->parseData($rawData);
          do {
              if (isset($data) && $data['time'] != '') {
                  try {
                      $this->db->query('
 INSERT IGNORE INTO
 aps_stat.operaz 
 (datetime, operaz, time) VALUES (
 "' . $data['datetime'] . '",
 "' . $data['operaz'] . '",
 ' . $data['time'] . ')', \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
                  } catch (\Exception $e) {
                      var_dump($data);
                      die;
                  }
              }
              $rawData = fgetcsv($statHandler, 100, ';');
              $data = $this->parseData($rawData);
          } while (is_array($rawData));
          fclose($statHandler);
      }
  }
コード例 #2
0
 /**
  * remove temp values
  */
 public function tearDown()
 {
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'categories');
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'feeds');
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'items');
     @unlink(Zend_Registry::get('config')->thumbnails->path . "thumb1.jpg");
     @unlink(Zend_Registry::get('config')->thumbnails->path . "thumb2.jpg");
 }
コード例 #3
0
ファイル: PowerDNS.php プロジェクト: appsoluut/MiniThor-core
 public function addRecord($domain, $name, $type, $content, $ttl = 86400, $prio = 0)
 {
     $domainId = $domain;
     if (!is_numeric($domain)) {
         $domainId = $this->getDomainId($domain);
     }
     $this->_db->insert('records', array('domain_id' => $domainId, 'name' => $name, 'type' => strtoupper($type), 'content' => trim($content), 'ttl' => intval($ttl), 'prio' => intval($prio)));
 }
コード例 #4
0
 public function _initZendDb(Yaf_Dispatcher $dispatcher)
 {
     $arrConfig = Yaf_Application::app()->getConfig();
     $zendDb = new Zend_Db();
     $params = array('host' => $arrConfig->mysql->read->host, 'username' => $arrConfig->mysql->read->username, 'password' => $arrConfig->mysql->read->password, 'dbname' => $arrConfig->mysql->read->dbname, 'port' => $arrConfig->mysql->read->port);
     $db = $zendDb->factory('PDO_MYSQL', $params);
     Yaf_Registry::set('db', $db);
 }
コード例 #5
0
 /**
  * remove temp values
  */
 public function tearDown()
 {
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'categories');
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'feeds');
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'items');
     $this->db->exec("DELETE FROM " . Zend_Registry::get('config')->resources->db->prefix . 'messages');
     @unlink(Zend_Registry::get('config')->favicons->path . "4711.ico");
     @unlink(Zend_Registry::get('config')->favicons->path . md5('http://rsslounge.aditu.de/favicon.ico') . '.ico');
     @unlink(Zend_Registry::get('config')->favicons->path . md5('http://blog.aditu.de/favicon.ico') . '.ico');
 }
コード例 #6
0
ファイル: Bootstrap.php プロジェクト: lukaszjankowski/alchemy
 protected function _initDb()
 {
     $resources = $this->getOption('resources');
     $dbConfig = $resources['db'];
     $db = \Zend_Db::factory($dbConfig['adapter'], array('host' => $dbConfig['params']['host'], 'username' => $dbConfig['params']['username'], 'password' => $dbConfig['params']['password'], 'dbname' => $dbConfig['params']['dbname'], 'adapterNamespace' => $dbConfig['params']['adapterNamespace']));
     \Zend_Db_Table::setDefaultAdapter($db);
 }
コード例 #7
0
ファイル: Db.php プロジェクト: BGCX262/zym-svn-to-git
 /**
  * Setup db
  *
  */
 public function setup(Zend_Config $config)
 {
     // Determine if config is for a single-db or a multi-db site
     $dbConfigs = isset($config->dbname) ? array($config) : $config->get('connection');
     foreach ($dbConfigs as $dbConfig) {
         // Merge default config
         $dbConfig = $this->_mergeConfig($config->get('default_config'), $dbConfig);
         // TODO: Cleanup config
         // Sigh, bad code in Zend_Db_Adapter_Abstract... we cannot have an empty string for profile class
         // Create db adapter
         $db = Zend_Db::factory($dbConfig->get('adapter'), $dbConfig->toArray());
         // Setup profiler
         $this->_setupProfiler($dbConfig->get('profiler'), $db);
         // Setup tables
         $this->_setupTables($dbConfig, $db);
         // Make sure db keys don't already exist, else add numbers to them such as db-2, db-3
         $dbKey = $this->_makeDbKey($dbConfig->get('registry')->get('key'));
         // Store db obj
         $this->setAdapter($db, $dbKey);
         // Determine if we should save the db adapter in the registry
         $dbRegistryDisabled = isset($dbConfig->get('registry')->disabled) && $dbConfig->get('registry')->get('disabled') === '' || $dbConfig->get('registry')->get('disabled') == true;
         if (!$dbRegistryDisabled) {
             // Save in registry
             Zend_Registry::set($dbKey, $db);
         }
     }
 }
コード例 #8
0
ファイル: Bootstrap.php プロジェクト: houtsnip/bruno_test
 protected function _database()
 {
     $this->_db = Zend_Db::factory('Pdo_Mysql', array('host' => 'localhost', 'username' => 'test_bruno', 'password' => 'test_bruno', 'dbname' => 'test_bruno'));
     $this->_db->exec("SET NAMES 'utf8'");
     Zend_Db_Table::setDefaultAdapter($this->_db);
     return $this;
 }
コード例 #9
0
ファイル: localString.php プロジェクト: rjon76/netspotapp
 public function __construct($siteId)
 {
     $this->siteId = $siteId;
     $this->dbAdapter = Zend_Registry::get('dbAdapter');
     $dbAdapter = Zend_Registry::get('dbAdapter');
     $config = Zend_Registry::get('config');
     $params = $config->db->config->toArray();
     //        	$params['dbname'] 	= 'venginse_all';
     $params['dbname'] = $config->db->config->dballname;
     $this->alldbAdapter = Zend_Db::factory($config->db->adapter, $params);
     $select = $dbAdapter->select();
     $select->from('sites', array('s_dbname', 's_path'));
     $select->where('s_id = ?', $siteId);
     $config = $dbAdapter->fetchRow($select->__toString());
     $this->siteDbName = $config['s_dbname'];
     $this->sitePath = $config['s_path'];
     include_once $this->sitePath . 'application/includes.inc.php';
     IniParser::getInstance()->setIni($this->sitePath . 'application/config.ini', TRUE);
     $config = Zend_Registry::get('config');
     $params = $config->db->config->toArray();
     $params['dbname'] = $this->siteDbName;
     $this->siteDbAdapter = Zend_Db::factory($config->db->adapter, $params);
     Zend_Registry::set('siteDbAdapter', $this->siteDbAdapter);
     $this->siteDbAdapter->query('SET NAMES utf8');
     $this->alldbAdapter->query('SET NAMES utf8');
     $this->loadLangs();
     $this->recCount = $this->countStrings();
     $this->recPerPage = 20;
 }
コード例 #10
0
ファイル: CrudTProvider.php プロジェクト: rtsantos/mais
 /**
  *
  * @param Zend_Tool_Project_Profile $profile
  * @param type $adapter
  * @throws Zend_Tool_Project_Exception 
  */
 private function _connect(Zend_Tool_Project_Profile $profile, $adapter, $env = 'development')
 {
     $applicationConfigResource = $profile->search('ApplicationConfigFile');
     if ($env == null || $env == '') {
         $env = 'development';
     }
     if (!$applicationConfigResource) {
         throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.');
     }
     //$conn = 'testing';
     //$conn = 'development';
     $zf = $applicationConfigResource->getAsZendConfig($env);
     $this->_print('Conectado em ' . $env);
     #$zf = $applicationConfigResource->getAsZendConfig('testing');
     $_configDb = $zf->resources->multidb->{$adapter};
     if (!$_configDb) {
         throw new Zend_Tool_Project_Exception('Adapter not found in config application "resources.multidb.' . $adapter . '" .');
     }
     $configDb = array();
     $configDb['host'] = $_configDb->host;
     $configDb['username'] = $_configDb->username;
     $configDb['password'] = $_configDb->password;
     $configDb['dbname'] = $_configDb->dbname;
     $configDb['adapterNamespace'] = $_configDb->adapterNamespace;
     $configDb['options']['caseFolding'] = 1;
     $this->_dbAdapter = Zend_Db::factory($_configDb->adapter, $configDb);
 }
コード例 #11
0
 /**
  * Connect to the database
  *
  * @param string $dbType Database adapter type for Zend_Db
  * @param array|object $dbDescription Adapter-specific connection settings
  * @return Zend_Db_Adapter_Abstract
  * @see Zend_Db::factory()
  */
 protected function _connect($dbType, $dbDescription)
 {
     if (is_object($dbDescription)) {
         $dbDescription = get_object_vars($dbDescription);
     }
     return Zend_Db::factory($dbType, $dbDescription);
 }
コード例 #12
0
ファイル: Mysql.php プロジェクト: JudonH/writer
 /**
  * 返回数据库连接
  * 从http服务器读取配置,格式: SetEnv DB_$dbid PDO_MYSQL/$ip/$port/$db/$user/$passwd/$charset
  * @param   mixed   $dbid   数据库连接代号
  * @return  object  Zend_Db对象
  */
 public static function getDb($dbid)
 {
     if (Esun_ConfigCenter::isExsitConfigcenter()) {
         $confinfo = Esun_ConfigCenter::getconfig("DB_{$dbid}");
     } else {
         $confinfo = $_SERVER['DB_' . $dbid];
     }
     $conf = explode('/', $confinfo);
     $params = array('host' => $conf[1], 'port' => (int) $conf[2], 'dbname' => $conf[3], 'username' => $conf[4], 'password' => $conf[5], 'charset' => $conf[6], 'options' => array(Zend_Db::AUTO_QUOTE_IDENTIFIERS => false));
     if (preg_match('/PDO_MSSQL/i', $conf[0])) {
         $params['pdoType'] = 'dblib';
         $params['options'][Zend_Db::CASE_FOLDING] = Zend_Db::CASE_UPPER;
     } elseif (preg_match('/ORACLE/i', $conf[0])) {
         if ($conf[1] && $conf[2]) {
             $params['dbname'] = "//{$conf[1]}:{$conf[2]}/{$conf[3]}";
         }
     }
     $db = Zend_Db::factory($conf[0], $params);
     if (preg_match('/PDO_MYSQL/i', $conf[0])) {
         $db->query("SET NAMES " . $conf[6]);
         $db->query("set session transaction isolation level read committed");
     } elseif (preg_match('/ORACLE|PDO_OCI/i', $conf[0])) {
         $db->query("alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'");
     }
     return $db;
 }
コード例 #13
0
ファイル: Db.php プロジェクト: arslbbt/mangentovies
 public function getResource()
 {
     if (!$this->_resource) {
         $this->_resource = Zend_Db::factory($this->getVar('adapter', 'Pdo_Mysql'), $this->getVars());
     }
     return $this->_resource;
 }
コード例 #14
0
 public function run()
 {
     // Lade Konfig
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     Zend_Registry::set('config', $config);
     // Erstelle DB Adapter
     $db = Zend_Db::factory($config->db);
     Zend_Registry::set('db', $db);
     Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('db'));
     if (APPLICATION_ENV !== 'production') {
         $profiler = new Zend_Db_Profiler_Firebug('All Database Queries:');
         $profiler->setEnabled(true);
         $db->setProfiler($profiler);
     }
     $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => ''));
     $resourceLoader->addResourceType('plugins', 'plugins', 'Plugins');
     if (PHP_SAPI != 'cli') {
         $front = Zend_Controller_Front::getInstance();
         $front->registerPlugin(new Plugins_Stats());
         if (APPLICATION_ENV == 'production') {
             $front->registerPlugin(new Plugins_Cache());
         }
     }
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('_partials/controls.phtml');
     parent::run();
 }
コード例 #15
0
ファイル: Kernel.php プロジェクト: albertobraschi/zstarter
 public static function setDbAdapter()
 {
     $cnf = Zend_Registry::get('cnf');
     $db = Zend_Db::factory($cnf->db);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     Zend_Registry::set('db', $db);
 }
コード例 #16
0
ファイル: Bootstrap.php プロジェクト: bucknejo/mtb
 protected function _initDb()
 {
     $config = Zend_Registry::get('config');
     $options = $config->mtb->db->params;
     $db = Zend_Db::factory('PDO_MYSQL', $options);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
 }
コード例 #17
0
 public function indexAction()
 {
     // $db=  Zend_Db::factory('pdo_mysql',array('dbname'=>'zendfw','host'=>'localhost','username'=>'root','password'=>''));
     $filename = APPLICATION_PATH . '/configs/config.ini';
     $config = new Zend_Config_Ini($filename);
     $config = $config->toArray();
     $configdb = $config['db'];
     $adapter = $configdb['adapter'];
     $params = $configdb[$adapter]['params'];
     $db = Zend_Db::factory($adapter, $params);
     var_dump($db);
     //        $userModel= new Default_Model_User();
     //        $userModel->addUser(array('name'=>'abc',
     //            'password'=>'123456',
     //            'fullname'=>'this is fullname'));
     //        $array_pdo= array(
     //            'id'=>'10',
     //            'name'=>'abc',
     //            'password'=>'123456',
     //            'fullname'=>'this is fullname',
     //        );
     //        $userModel->addUser($array_pdo);
     //        // $userModel->select();
     //
     //        $test= new My_Db_Mysql();
     //        $test->test();
     $this->_helper->viewRenderer->setNoRender(true);
 }
コード例 #18
0
ファイル: Select.php プロジェクト: gatorv/gecko_fw1
 /**
  * Creates and populates the DataSource
  *
  * @access public
  * @return void
  **/
 public function setup()
 {
     $select = $this->getSelect();
     if ($this->paginate) {
         $sql = $this->getSelectCountSql();
         $this->totalRows = (int) $this->_db->fetchOne($sql);
         list($start, $total) = $this->limit;
         $select->reset(Zend_Db_Select::LIMIT_COUNT);
         $select->reset(Zend_Db_Select::LIMIT_OFFSET);
         $select->limit($total, $start);
     } else {
         $this->totalRows = 0;
     }
     $select->reset(Zend_Db_Select::ORDER);
     if (count($this->order) > 0) {
         $select->order($this->order);
     }
     // Fetch Select Columns
     $rawColumns = $select->getPart(Zend_Db_Select::COLUMNS);
     $columns = array();
     // Get columns and Force casting as strings
     foreach ($rawColumns as $col) {
         $columns[] = (string) $col[1];
     }
     $this->cols = $columns;
     $this->totalColumns = count($columns);
     // Fetch
     $stmt = $this->_db->query($select);
     $rows = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     $total = count($rows);
     $this->totalRowset = $total;
     $this->rows = $rows;
 }
コード例 #19
0
ファイル: Bootstrap.php プロジェクト: kaibaok/xs
 protected function _initDB()
 {
     $db = Zend_Db::factory('Pdo_Mysql', array('host' => 'localhost', 'username' => 'root', 'password' => '', 'dbname' => 'xoso', 'charset' => 'utf8'));
     $db->setFetchMode(Zend_Db::FETCH_BOTH);
     Zend_Db_Table::setDefaultAdapter($db);
     return $db;
 }
コード例 #20
0
ファイル: IndexController.php プロジェクト: psykomo/kutump
 public function testAction()
 {
     $time_start = microtime(true);
     $params = array('host' => '127.0.0.1', 'username' => 'root', 'password' => 'root', 'dbname' => 'langithp');
     $db = Zend_Db::factory('PDO_MYSQL', $params);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     require_once '/Users/n/Documents/Work/Zend/kutump/test/CatalogAttribute.php';
     $tbl = new CatalogAttribute();
     $rows = $tbl->fetchAll();
     $num = count($rows);
     echo "<b><center>Database Output</center></b><br><br>";
     $i = 0;
     for ($i = 0; $i < $num; $i++) {
         //$tmpGuid = mysql_result($result,$i,"guid");
         $row = $rows->current();
         $tmpGuid = $row->title;
         echo '<br>' . $tmpGuid;
         echo '<br>' . $i;
         $rows->next();
         //$i++;
     }
     $dbh = null;
     echo '<br>Total: ' . $i;
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     echo '<br>WAKTU EKSEKUSI: ' . $time;
     //die('hiho');
 }
コード例 #21
0
ファイル: uc.php プロジェクト: saintho/wecenter
 function uc_note()
 {
     require_once AWS_PATH . '/config/database.php';
     $this->tablepre = $config['prefix'];
     $this->db = Zend_Db::factory($config['driver'], $config['master']);
     $this->db->query("SET NAMES " . $config['charset']);
 }
コード例 #22
0
 public function __construct()
 {
     //set country
     //lookup country from subdomain
     // must be format like http://country.site.org
     $parts = explode('.', $_SERVER['HTTP_HOST']);
     self::$COUNTRY = $parts[0];
     require_once 'settings.php';
     $countryLoaded = false;
     if ($parts[1] == 'trainingdata') {
         Settings::$DB_DATABASE = Globals::$DB_TABLE_PREFIX . $parts[0];
         self::$COUNTRY = $parts[0];
         Settings::$COUNTRY_BASE_URL = 'http://' . $parts[0] . '.' . Globals::$DOMAIN;
         $countryLoaded = true;
     }
     error_reporting(E_ALL);
     // PATH_SEPARATOR =  ; for windows, : for *nix
     $iReturn = ini_set('include_path', Globals::$BASE_PATH . PATH_SEPARATOR . Globals::$BASE_PATH . 'app' . PATH_SEPARATOR . (Globals::$BASE_PATH . 'ZendFramework' . DIRECTORY_SEPARATOR . 'library') . PATH_SEPARATOR . ini_get('include_path'));
     require_once 'Zend/Loader.php';
     if ($countryLoaded) {
         //fixes mysterious configuration issue
         require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
         require_once 'Zend/Db.php';
         //set a default database adaptor
         $db = Zend_Db::factory('PDO_MYSQL', array('host' => Settings::$DB_SERVER, 'username' => Settings::$DB_USERNAME, 'password' => Settings::$DB_PWD, 'dbname' => Settings::$DB_DATABASE));
         require_once 'Zend/Db/Table/Abstract.php';
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
     }
 }
コード例 #23
0
ファイル: zit_db_adapter.php プロジェクト: Koulio/OpenZIS
 private function __construct()
 {
     $config = new Zend_Config_Ini('../config.ini', 'zit_config');
     $type = $config->database;
     $host = $config->host;
     $username = $config->username;
     $password = $config->password;
     $dbname = $config->dbname;
     $sleep = $config->dbsleep;
     $dbAdapter = null;
     if ($sleep == null) {
         $_SESSION['SLEEP'] = 0;
     } else {
         $_SESSION['SLEEP'] = $sleep;
     }
     define('DB_TYPE', $type);
     switch (DB_TYPE) {
         case 'mysql':
             $pdoParams = array(PDO::ATTR_CASE => PDO::CASE_LOWER, PDO::ATTR_EMULATE_PREPARES => true);
             $options = array(Zend_Db::CASE_FOLDING => Zend_Db::CASE_LOWER);
             $params = array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $dbname, 'options' => $options, 'driver_options' => $pdoParams);
             $this->adapter = Zend_Db::factory('Pdo_Mysql', $params);
             $this->adapter->setFetchMode(Zend_Db::FETCH_OBJ);
             break;
         case 'oci8':
             $params = array('username' => $username, 'password' => $password, 'dbname' => $dbname, 'charset' => 'utf8');
             $this->adapter = Zend_Db::factory('Oracle', $params);
             $this->adapter->setFetchMode(Zend_Db::FETCH_OBJ);
             $this->adapter->setLobAsString(true);
             break;
     }
 }
コード例 #24
0
 /**
  * Verifies database connection information
  *
  * @param array $words List of words to censor (from input). Keys: word, exact, replace
  * @param XenForo_DataWriter $dw Calling DW
  * @param string $fieldName Name of field/option
  *
  * @return true
  */
 public static function verifyOption(array &$database, XenForo_DataWriter $dw = null, $fieldName = null)
 {
     if (array_key_exists('newInstall', $database)) {
         return true;
     }
     if (!array_key_exists('adapter', $database) || !array_key_exists('host', $database) || !array_key_exists('port', $database) || !array_key_exists('dbname', $database) || !array_key_exists('username', $database) || !array_key_exists('password', $database)) {
         return false;
     }
     try {
         $db = Zend_Db::factory($database['adapter'], array('host' => $database['host'], 'port' => $database['port'], 'dbname' => $database['dbname'], 'username' => $database['username'], 'password' => $database['password']));
         $db->getConnection();
         $sbTables = array($database['table_prefix'] . '_admins', $database['table_prefix'] . '_admins_servers_groups', $database['table_prefix'] . '_banlog', $database['table_prefix'] . '_bans', $database['table_prefix'] . '_comments', $database['table_prefix'] . '_demos', $database['table_prefix'] . '_groups', $database['table_prefix'] . '_log', $database['table_prefix'] . '_mods', $database['table_prefix'] . '_overrides', $database['table_prefix'] . '_protests', $database['table_prefix'] . '_servers', $database['table_prefix'] . '_servers_groups', $database['table_prefix'] . '_settings', $database['table_prefix'] . '_srvgroups', $database['table_prefix'] . '_srvgroups_overrides', $database['table_prefix'] . '_submissions');
         $query = $db->listTables();
         if (count(array_diff($sbTables, $query)) > 0) {
             $dw->error(new XenForo_Phrase('sourcebans_table_prefix_invalid'));
             return false;
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         if ($dw) {
             $dw->error($e->getMessage(), $fieldName);
         }
         return false;
     }
     return true;
 }
コード例 #25
0
 public function getResource()
 {
     if (!$this->_resource) {
         $this->_resource = Zend_Db::factory($this->getVar('type'), $this->getVars());
     }
     return $this->_resource;
 }
コード例 #26
0
ファイル: Common.php プロジェクト: jorgenils/zend-framework
 function setUp()
 {
     // open a new connection
     $this->_db = Zend_Db::factory($this->getDriver(), $this->getParams());
     // create a test table and populate it
     $this->createTestTable();
 }
コード例 #27
0
    /**
     * Test AUTO_QUOTE_IDENTIFIERS option
     * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true
     *
     * SQLite actually allows delimited identifiers to remain
     * case-insensitive, so this test overrides its parent.
     */
    public function testAdapterAutoQuoteIdentifiersTrue()
    {
        $params = $this->_util->getParams();

        $params['options'] = array(
            Zend_Db::AUTO_QUOTE_IDENTIFIERS => true
        );
        $db = Zend_Db::factory($this->getDriver(), $params);
        $db->getConnection();

        $select = $this->_db->select();
        $select->from('zfproducts');
        $stmt = $this->_db->query($select);
        $result1 = $stmt->fetchAll();

        $this->assertEquals(1, $result1[0]['product_id']);

        $select = $this->_db->select();
        $select->from('ZFPRODUCTS');
        try {
            $stmt = $this->_db->query($select);
            $result2 = $stmt->fetchAll();
        } catch (Zend_Exception $e) {
            $this->assertType('Zend_Db_Statement_Exception', $e,
                'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e));
            $this->fail('Unexpected exception '.get_class($e).' received: '.$e->getMessage());
        }

        $this->assertEquals($result1, $result2);
    }
コード例 #28
0
ファイル: Creator.php プロジェクト: rocknoon/TCVM
 private static function _createAdapter()
 {
     $adapter = self::_getZendAdapterName(WeFlex_Application::GetInstance()->config->db->adapter);
     /**
      * $TODO check the following validate
      */
     $database = WeFlex_Application::GetInstance()->config->db->database;
     $username = WeFlex_Application::GetInstance()->config->db->user;
     $password = WeFlex_Application::GetInstance()->config->db->pwd;
     $host = WeFlex_Application::GetInstance()->config->db->host;
     /**
      * @todo if the adapter is exsit , we could not create it , and get it from registry
      */
     $zendAdapter = Zend_Db::factory($adapter, array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $database));
     /**
      * hack for debugger;
      */
     if (WeFlex_Application::GetInstance()->config->db->usefirephp) {
         $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
         $profiler->setEnabled(true);
         $zendAdapter->setProfiler($profiler);
     }
     $zendAdapter->getConnection();
     $zendAdapter->query("SET NAMES 'utf8'");
     return $zendAdapter;
 }
コード例 #29
0
ファイル: util.php プロジェクト: openbizx/openbizx-cubix
function connectDB($noDB = false)
{
    require_once 'Zend/Db.php';
    // Automatically load class Zend_Db_Adapter_Pdo_Mysql and create an instance of it.
    $param = array('host' => $_REQUEST['dbHostName'], 'username' => $_REQUEST['dbUserName'], 'password' => $_REQUEST['dbPassword'], 'port' => $_REQUEST['dbHostPort'], 'dbname' => $_REQUEST['dbName']);
    if ($noDB) {
        $param['dbname'] = '';
    }
    try {
        $db = Zend_Db::factory($_REQUEST['dbtype'], $param);
        $conn = $db->getConnection();
    } catch (Zend_Db_Adapter_Exception $e) {
        // perhaps a failed login credential, or perhaps the RDBMS is not running
        echo 'ERROR: ' . $e->getMessage();
        exit;
    } catch (Zend_Exception $e) {
        // perhaps factory() failed to load the specified Adapter class
        echo 'ERROR: ' . $e->getMessage();
        exit;
    }
    //if its connected then test is database empty
    if (!$noDB) {
        $tables = $db->listTables();
        if (count($tables)) {
            echo 'ERROR: ' . STR_DATABASE_NOT_EMPTY;
            exit;
        }
    }
    return $conn;
}
コード例 #30
0
ファイル: Database.php プロジェクト: ngukho/ducbui-cms
 public function connect($name, $host, $username, $password, $adapter)
 {
     $this->_config = array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $name);
     $this->_db = Zend_Db::factory($adapter, $this->_config);
     $this->_db->query("SET NAMES 'utf8'");
     $this->_db->query("SET CHARACTER SET 'utf8'");
 }