public function get() { if (count($this->idle_pool) > 0) { //返回空闲的连接 ++$this->connection_num; return array_pop($this->idle_pool); } else { //不存在空闲连接 if ($this->connection_num >= $this->pool_size) { //连接数达到连接池容量最大值 mPHP::_exit(); return false; } //创建新连接 ++$this->connection_num; mPHP::$db = new pdoModel($this->db_config); return mPHP::$db; } }
public function cache($file, $cacheTime) { $this->is_cache = true; $time = $_SERVER['REQUEST_TIME']; $createTime = file_exists($file) ? filemtime($file) : 0; if ($createTime + $cacheTime >= $time && !mPHP::$debug) { $createTime = date("D, d M Y H:i:s", $createTime); mPHP::header('Cache-Control', 'max-age=0'); mPHP::header('Last-Modified', $createTime); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $createTime) { mPHP::status(304); } else { include $file; } mPHP::_exit(); return true; } return false; }
function P($val, $true = true) { echo '<pre>'; if (is_array($val)) { print_r($val); } else { var_dump($val); } echo '</pre>'; if ($true) { mPHP::_exit(); } }