/** * 设置 Model 类型对象 * * @param Model $model */ public function setModelObject(Model $model) { $config = $model->getConnection(); self::$table = $config['tablename']; $this->setConfig($config); self::$model = $model; }
define('DB_PASS', $config[$db_group]['password']); define('TABLE_PREFIX', $config[$db_group]['prefix']); define('USE_PDO', $config[$db_group]['pdo']); if (USE_PDO) { try { $__SE_CONN__ = new PDO(DB_DSN, DB_USER, DB_PASS); } catch (PDOException $error) { die('DB Connection failed: ' . $error->getMessage()); } if ($__SE_CONN__->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { $__SE_CONN__->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } } else { require_once SYSPATH . '/libraries/DoLite.php'; $__SE_CONN__ = new DoLite(DB_DSN, DB_USER, DB_PASS); } Model::connection($__SE_CONN__); Model::getConnection()->exec("set names 'utf8'"); } // Set debugger define('DEBUG', $config['debug']); /** * Get all routes and process them */ if (isset($route)) { foreach ($route as $key => $value) { SE::addRoute($key, $value); } } // Dispatch Simplengine SE::dispatch();
/** * O método Model::escape() prepara dados para uso em consultas SQL, retirando * caracteres que possam ser perigosos, evitando possíveis ataques de SQL Injection. */ public function escape($data) { if (get_magic_quotes_gpc()) { $data = stripslashes($data); } return mysql_real_escape_string($data, Model::getConnection()); }