/** * Contructor initializes the object * * @access public * @param ConnectionSetting $csetting * @param Observable $listener * @param IDataDriver (optional) if not provided, then DataAdapter will attempt to instantiate one based on ConnectionSetting->Type */ function __construct($csetting, $listener = null, IDataDriver $driver = null) { $this->_driver = $driver; if ($this->_driver == null) { // the driver was not explicitly provided so we will try to create one from // the connection setting based on the database types that we do know about switch ($csetting->Type) { case "mysql": include_once "verysimple/DB/DataDriver/MySQL.php"; $this->_driver = new DataDriverMySQL(); break; case "sqlite": include_once "verysimple/DB/DataDriver/SQLite.php"; $this->_driver = new DataDriverSQLite(); break; default: include_once "verysimple/DB/DataDriver/" . $csetting->Type . ".php"; $classname = "DataDriver" . $csetting->Type; $this->_driver = new $classname(); break; } } DataAdapter::$DRIVER_INSTANCE = $this->_driver; $this->AttachObserver($listener); $this->_csetting =& $csetting; $this->Observe("DataAdapter Instantiated", OBSERVE_DEBUG); }
/** * @brief Methode qui permet la creation d'une table * @details * @param name Nom de la table a creer * @param params Array contenant la description a suivre pour la creation de la table */ public static function createTable($name, $params = array(), $table = array()) { if (!empty($name)) { $query = "CREATE TABLE IF NOT EXISTS " . $name . " (id mediumint(9) NOT NULL AUTO_INCREMENT, "; foreach ($params as $fieldname => $val) { $sqltype = DataAdapter::getSqlTypeFromStdType($val['type']); if ($val['type'] == 'join') { $query .= " {$fieldname} " . $sqltype . " NOT NULL, "; } else { if ($val['type'] == 'date') { $query .= " {$fieldname} " . $sqltype . " NOT NULL, "; } else { if ($val['type'] == 'largetext') { $query .= " {$fieldname} " . $sqltype . " NOT NULL, "; } else { if ($val['type'] == 'text') { $query .= " {$fieldname} " . $sqltype . " NOT NULL, "; } else { $query .= " {$fieldname} " . $sqltype . " NOT NULL, "; } } } } } $query .= " PRIMARY KEY (id)) ENGINE="; // Si le moteur de table est spécifié if (isset($table['engine'])) { $query .= $table['engine']; } else { $query .= "MyISAM"; } $query .= " DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; "; sql::query($query); if (sql::errorNo()) { echo sql::error(); } if (sql::$display) { echo "\n Table de travail : " . $name . " crée \n\n"; } } }
/** * Utility method that calls DataAdapter::GetQuotedSql($val) * @param variant $val to be quoted * @return string */ private function GetQuotedSql($val) { return DataAdapter::GetQuotedSql($val); }
/** * Returns DataAdapter::GetQuotedSql($val) * @param variant $val to be quoted * @return string */ public function GetQuotedSql($val) { return DataAdapter::GetQuotedSql($val); }
public function __construct($jsonString) { parent::__construct($jsonString); }
/** * */ public function Escape($val) { return DataAdapter::Escape($val); }
/** * Load the data driver * @throws Exception */ public function LoadDriver() { if ($this->_driver == null) { require_once "verysimple/IO/Includer.php"; // the driver was not explicitly provided so we will try to create one from // the connection setting based on the database types that we do know about switch ($this->ConnectionSetting->Type) { case "mysql": include_once "verysimple/DB/DataDriver/MySQL.php"; $this->_driver = new DataDriverMySQL(); break; case "mysqli": include_once "verysimple/DB/DataDriver/MySQLi.php"; $this->_driver = new DataDriverMySQLi(); break; case "sqlite": include_once "verysimple/DB/DataDriver/SQLite.php"; $this->_driver = new DataDriverSQLite(); break; default: try { Includer::IncludeFile("verysimple/DB/DataDriver/" . $this->ConnectionSetting->Type . ".php"); $classname = "DataDriver" . $this->ConnectionSetting->Type; $this->_driver = new $classname(); } catch (IncludeException $ex) { throw new Exception('Unknown DataDriver "' . $this->ConnectionSetting->Type . '" specified in connection settings'); } break; } DataAdapter::$DRIVER_INSTANCE = $this->_driver; } }