static function getDBConn() { if (self::$_db != null) { return self::$_db; } else { self::$_db = Zend_DB::factory(self::getConfig()->sumaserver->db->platform, array('host' => self::getConfig()->sumaserver->db->host, 'username' => self::getConfig()->sumaserver->db->user, 'password' => self::getConfig()->sumaserver->db->pword, 'dbname' => self::getConfig()->sumaserver->db->dbname, 'port' => self::getConfig()->sumaserver->db->port)); self::$_db->query('SET NAMES utf8'); self::$_db->setFetchMode(Zend_Db::FETCH_ASSOC); return self::$_db; } }
function databases($pReload = FALSE) { if ($pReload || is_null($this->_databases)) { $value = array(); if ($this->info()->databases) { foreach ($this->info()->databases as $key => $db) { if (!$db->adapter) { $db->adapter = 'mysqli'; } $value[$key] = Zend_DB::factory($db); } } // process $this->_databases = $value; } return $this->_databases; }
try { $index = Zend_Search_Lucene::create($indexpath); $log->info("Created new index in {$indexpath}"); // If both fail, give up and show error message } catch (Zend_Search_Lucene_Exception $e) { $log->info("Failed opening or creating index in {$indexpath}"); $log->info($e->getMessage()); echo "Unable to open or create index: {$e->getMessage()}"; exit(1); } $log->info('Crawler loads db'); // load DB configuration $config = new Zend_Config_Ini('../config/zportal.ini', 'database'); Zend_Registry::set('config', $config); // create DB connection $db = Zend_DB::factory($config->adapter, $config->params->toArray()); /* @var $db Zend_DB_Adapter_Abstract */ // Store database handler as default adapter Zend_Db_Table_Abstract::setDefaultAdapter($db); $table = new Feeds(); $list = $table->fetchAll(); $targets = 0; foreach ($list as $item) { if ($item->type != 'feed') { continue; } $log->info("Fetched " . $item->url); $xml = file_get_contents($item->url); if (!$xml) { $log->info("Error fetching " . $item->url); continue;
/** * Deletes all our fixtures tables. * * @access public * @return bool True on success, false otherwise. * */ public function dropTables() { $fixtures = $this->_db->listTables(); if (count($fixtures) === 0) { throw new ErrorException('No fixture tables to drop.'); } try { foreach ($fixtures as $fixture) { $this->dropTable($fixture); } } catch (Exception $e) { echo $e->getMessage(); } return true; }