public function initDatabase() { // Establish database connection or return false. if (!($this->dbConnection = DBConnectionStack::getConnection())) { return false; } // Get Zikula table data or return false. if (!($this->dbTables = DBUtil::getTables())) { return false; } // Return success. return true; }
public function upgrade($oldversion) { $dom = ZLanguage::getModuleDomain('IWbooks'); switch ($oldversion) { case 0.8: $dbconn = & DBConnectionStack::getConnection(true); $pntable = & DBUtil::getTables(); $llibrestable = $pntable['llibres']; $llibrescolumn = &$pntable['llibres_column']; $sql = "ALTER TABLE $llibrestable CHANGE $llibrescolumn[etapa] $llibrescolumn[etapa] varchar(32) NOT NULL default ''"; $dbconn->Execute($sql); $sql = "ALTER TABLE $llibrestable DROP pn_tipus"; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { SessionUtil::setVar('errormsg', __('Failed to update the tables', $dom)); return false; } ModUtil::setVar('IWbooks', 'plans', ' PRI#Educació Primària| ESO#Educació Secundària Obligatòria| BTE#Batxillerat Tecnològic| BSO#Batxillerat Social| BHU#Batxillerat Humanístic| BCI#Batxillerat Científic| BAR#Batxillerat Artístic'); ModUtil::setVar('IWbooks', 'darrer_nivell', '4'); return IWbooks_upgrade(0.9); case 0.9: // Codi per a versió 1.0 $dbconn = & DBConnectionStack::getConnection(true); $pntable = & DBUtil::getTables(); $llibrestable = $pntable['llibres']; $llibrescolumn = &$pntable['llibres_column']; $sql = "ALTER TABLE $llibrestable ADD pn_observacions varchar(100) NOT NULL, ADD pn_materials text NOT NULL"; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { SessionUtil::setVar('errormsg', $llibrestable . $oldversion . __('Failed to update the tables', $dom)); return false; } ModUtil::setVar('IWbooks', 'llistar_materials', '1'); ModUtil::setVar('IWbooks', 'mida_font', '11'); ModUtil::setVar('IWbooks', 'marca_aigua', '0'); return IWbooks_upgrade(1.0); case 1.0: // Codi per a versió 2.0 ModUtil::delVar('IWbooks', 'darrer_nivell'); ModUtil::setVar('IWbooks', 'nivells', ' 1#1r| 2#2n| 3#3r| 4#4t| 5#5è| 6#6è| A#P3| B#P4| C#P5'); if (!DBUtil::changeTable('IWbooks')) { return false; } if (!DBUtil::changeTable('IWbooks_materies')) { return false; } return IWbooks_upgrade(2.0); break; } // Actualització amb èxit return true; }
/** * Initialize a DBConnection and place it on the connection stack. * * @param string $name The database alias name in the DBInfo configuration array (optional) (default=null which then defaults to 'default'). * @param boolean $lazyConnect Whether or not to connect lazy. * * @deprecated * * @throws PDOException If database connection failed. * @return Doctrine_Connection Desired database connection reference. */ public static function init($name = 'default', $lazyConnect = false) { LogUtil::log(__f('Warning! %1$s is deprecated.', array(__CLASS__ . '::' . __FUNCTION__)), E_USER_DEPRECATED); $serviceManager = ServiceUtil::getManager(); $eventManager = EventUtil::getManager(); // Lazy load DB connection to avoid testing DSNs that are not yet valid (e.g. no DB created yet) $dbEvent = new Zikula_Event('doctrine.init_connection', null, array('lazy' => $lazyConnect, 'name' => $name)); $connection = $eventManager->notify($dbEvent)->getData(); if (!self::$manager instanceof Doctrine_Manager) { self::$manager = Doctrine_Manager::getInstance(); } $databases = $serviceManager['databases']; self::$connectionInfo[$name] = $databases[$name]; return $connection; }
public function anullades($args) { //Comprovaci� de seguretat. Si falla retorna una matriu buida $registres = array(); if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_READ)) { return $registres; } extract($args); //Connectem amb la base de dades list($dbconn) = DBConnectionStack::getConnection(); $pntable = & DBUtil::getTables(); $t = $pntable['IWbookings']; $c = $pntable['IWbookings_column']; ($sid == -1) ? $espai = '' : $espai = $c[sid] . '=' . $sid . ' AND '; $sql = "SELECT $c[bid],$c[user],$c[start],$c[end],$c[usrgroup],$c[temp] FROM $t WHERE $espai $c[anulla]=1 ORDER BY $c[start]"; $registre = $dbconn->Execute($sql); //Comprovem que la consulta hagi estat amb �xit if ($dbconn->ErrorNo() != 0) { SessionUtil::setVar('errormsg', $this->__('An error has occurred while getting registers from the data base. Please, contact webmaster')); return false; } //Recorrem els registres i els posem dins de la matriu for (; !$registre->EOF; $registre->MoveNext()) { list($bid, $usuari, $inici, $final, $grup, $temp) = $registre->fields; //Comprovaci� de seguretat if (SecurityUtil::checkPermission('IWbookings::', "$usuari::$sid", ACCESS_READ)) { $registres[] = array('inici' => $inici, 'final' => $final, 'bid' => $bid, 'usuari' => $usuari, 'grup' => $grup, 'temp' => $temp); } } //Tanquem la BD $registre->Close(); //Retornem la matriu plena de registres return $registres; }