diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/README.txt b/README.txt index f6f92c4..6d02649 100644 --- a/README.txt +++ b/README.txt @@ -107,6 +107,14 @@ OR require_once "DbSimple/Connect.php"; $DB = new DbSimple_Connect("pgsql://login:password@host/database"); +OR + +You can use PDO DSN syntax (socket connections currently supported only with MySQL providers): + +require_once "DbSimple/Connect.php"; +$DB = new DbSimple_Connect("mysqli:unix_socket=/cloudsql/app:instance;user=root;pass=;dbname=testdb"); + + Listing 2: Fetch all resulting rows $rows = $DB->select('SELECT * FROM ?_user LIMIT 10'); diff --git a/lib/DbSimple/CacherImpl.php b/lib/DbSimple/CacherImpl.php new file mode 100644 index 0000000..986cb13 --- /dev/null +++ b/lib/DbSimple/CacherImpl.php @@ -0,0 +1,45 @@ +callback = $callback; + } else { + $this->callback = $this->callbackDummy; + } + } + + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) {} + + public function remove($id) {} + + public function test($id) {} + + public function save($data, $id, $tags = array(), $specificLifetime = false) + { + return call_user_func($this->callback, $id, $data); + } + + public function load($id, $doNotTestCacheValidity = false) + { + return call_user_func($this->callback, $id); + } + + public function setDirectives($directives) {} + + protected function callbackDummy($k, $v) + { + return null; + } + +} // CacherImpl class \ No newline at end of file diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php index 4706069..6489c89 100644 --- a/lib/DbSimple/Connect.php +++ b/lib/DbSimple/Connect.php @@ -118,7 +118,7 @@ protected function connect($dsn) if (!isset($parsed['scheme'])) $this->errorHandler('Невозможно загрузить драйвер базы данных', $parsed); $this->shema = ucfirst($parsed['scheme']); - require_once dirname(__FILE__).'/'.$this->shema.'.php'; + require_once __DIR__.'/'.$this->shema.'.php'; $class = 'DbSimple_'.$this->shema; $this->DbSimple = new $class($parsed); $this->errmsg = &$this->DbSimple->errmsg; @@ -256,18 +256,7 @@ public function setCachePrefix($prx) */ protected function parseDSN($dsn) { - $parsed = parse_url($dsn); - if (!$parsed) - return null; - $params = null; - if (!empty($parsed['query'])) - { - parse_str($parsed['query'], $params); - $parsed += $params; - } - $parsed['dsn'] = $dsn; - return $parsed; + return DbSimple_Generic::parseDSN($dsn); } -} -?> +} diff --git a/lib/DbSimple/Database.php b/lib/DbSimple/Database.php old mode 100644 new mode 100755 index 1a3a6ad..86719ae --- a/lib/DbSimple/Database.php +++ b/lib/DbSimple/Database.php @@ -74,6 +74,15 @@ if (!defined('DBSIMPLE_PARENT_KEY')) define('DBSIMPLE_PARENT_KEY', 'PARENT_KEY'); // forrest-based resultset support + +if ( !interface_exists('Zend_Cache_Backend_Interface', false) ) { + require_once __DIR__ . '/Zend/Cache.php'; + require_once __DIR__ . '/Zend/Cache/Backend/Interface.php'; +} + +require_once __DIR__ . '/CacherImpl.php'; + + /** * * Base class for all databases. @@ -262,10 +271,24 @@ public function setLogger($logger) * Set cache mechanism called during each query if specified. * Returns previous handler. */ - public function setCacher(Zend_Cache_Backend_Interface $cacher=null) + public function setCacher($cacher=null) { $prev = $this->_cacher; - $this->_cacher = $cacher; + + if ( is_null($cacher) ) { + return $prev; + } + + if ($cacher instanceof Zend_Cache_Backend_Interface) { + $this->_cacher = $cacher; + return $prev; + } + + if ( is_callable($cacher) ) { + $this->_cacher = new CacherImpl($cacher); + return $prev; + } + return $prev; } @@ -444,7 +467,7 @@ private function _query($query, &$total) $rows = false; $cache_it = false; // Кешер у нас либо null либо соответствует Zend интерфейсу - if (!empty($this->attributes['CACHE']) && $this->_cacher) + if ( !empty($this->attributes['CACHE']) && ($this->_cacher instanceof Zend_Cache_Backend_Interface) ) { $hash = $this->_cachePrefix . md5(serialize($query)); @@ -1323,7 +1346,7 @@ public function addIgnoreInTrace($name) * Return part of stacktrace before calling first library method. * Used in debug purposes (query logging etc.). */ - protected function findLibraryCaller() + public function findLibraryCaller() { $caller = call_user_func( array(&$this, 'debug_backtrace_smart'), @@ -1387,4 +1410,3 @@ private function debug_backtrace_smart($ignoresRe=null, $returnCaller=false) } } -?> diff --git a/lib/DbSimple/Generic.php b/lib/DbSimple/Generic.php old mode 100644 new mode 100755 index 919cd63..5dc2f14 --- a/lib/DbSimple/Generic.php +++ b/lib/DbSimple/Generic.php @@ -85,8 +85,17 @@ class DbSimple_Generic * Universal static function to connect ANY database using DSN syntax. * Choose database driver according to DSN. Return new instance * of this driver. + * + * You can connect to MySQL by socket using this new syntax (like PDO DSN): + * $dsn = 'mysqli:unix_socket=/cloudsql/app:instance;user=root;pass=;dbname=testdb'; + * $dsn = 'mypdo:unix_socket=/cloudsql/app:instance;charset=utf8;user=testuser;pass=mypassword;dbname=testdb'; + * + * Connection by host also can be made with this syntax. + * Or you can use old syntax: + * $dsn = 'mysql://testuser:mypassword@127.0.0.1/testdb'; + * */ - function connect($dsn) + public static function connect($dsn) { // Load database driver and create its instance. $parsed = DbSimple_Generic::parseDSN($dsn); @@ -96,7 +105,7 @@ function connect($dsn) } $class = 'DbSimple_'.ucfirst($parsed['scheme']); if (!class_exists($class)) { - $file = dirname(__FILE__).'/'.ucfirst($parsed['scheme']). ".php"; + $file = __DIR__.'/'.ucfirst($parsed['scheme']). ".php"; if (is_file($file)) { require_once($file); } else { @@ -118,19 +127,67 @@ function connect($dsn) * Parse a data source name. * See parse_url() for details. */ - function parseDSN($dsn) + public static function parseDSN($dsn) { if (is_array($dsn)) return $dsn; $parsed = parse_url($dsn); if (!$parsed) return null; + $params = null; if (!empty($parsed['query'])) { parse_str($parsed['query'], $params); $parsed += $params; } + + if ( empty($parsed['host']) && empty($parsed['socket']) ) { + // Parse as DBO DSN string + $parsedPdo = self::parseDsnPdo($parsed['path']); + unset($parsed['path']); + $parsed = array_merge($parsed, $parsedPdo); + } + $parsed['dsn'] = $dsn; return $parsed; - } -} + } // parseDSN + + + /** + * Parse string as DBO DSN string. + * + * @param $str + * @return array + */ + public static function parseDsnPdo($str) { + + if (substr($str, 0, strlen('mysql:')) == 'mysql:') { + $str = substr($str, strlen('mysql:')); + } + + $arr = explode(';', $str); + + $result = array(); + foreach ($arr as $k=>$v) { + $v = explode('=', $v); + if (count($v) == 2) + $result[ $v[0] ] = $v[1]; + } + + if ( isset($result['unix_socket']) ) { + $result['socket'] = $result['unix_socket']; + unset($result['unix_socket']); + } + + if ( isset($result['dbname']) ) { + $result['path'] = $result['dbname']; + unset($result['dbname']); + } + + if ( isset($result['charset']) ) { + $result['enc'] = $result['charset']; + unset($result['charset']); + } + + return $result; + } // parseDsnPdo -?> +} // DbSimple_Generic class diff --git a/lib/DbSimple/Ibase.php b/lib/DbSimple/Ibase.php index 839feef..a7e6f31 100644 --- a/lib/DbSimple/Ibase.php +++ b/lib/DbSimple/Ibase.php @@ -16,7 +16,7 @@ * * @version 2.x $Id$ */ -require_once dirname(__FILE__) . '/Database.php'; +require_once __DIR__ . '/Database.php'; /** * Best transaction parameters for script queries. @@ -284,5 +284,3 @@ function _firstUse() return true; } } - -?> \ No newline at end of file diff --git a/lib/DbSimple/Litepdo.php b/lib/DbSimple/Litepdo.php index 8c6b523..30ab9f7 100644 --- a/lib/DbSimple/Litepdo.php +++ b/lib/DbSimple/Litepdo.php @@ -15,7 +15,7 @@ * * @version 2.x $Id$ */ -require_once dirname(__FILE__).'/Database.php'; +require_once __DIR__.'/Database.php'; /** * Database class for SQLite. @@ -150,5 +150,3 @@ protected function _performFetch($result) } } - -?> \ No newline at end of file diff --git a/lib/DbSimple/Mssql.php b/lib/DbSimple/Mssql.php index de6af91..41b62cf 100644 --- a/lib/DbSimple/Mssql.php +++ b/lib/DbSimple/Mssql.php @@ -16,7 +16,7 @@ * * @version 2.x $Id: Mssql.php 163 2007-01-10 09:47:49Z dk $ */ -require_once dirname(__FILE__) . '/Generic.php'; +require_once __DIR__ . '/Generic.php'; /** @@ -43,7 +43,7 @@ function DbSimple_Mssql($dsn) ); $this->_resetLastError(); if (!$ok) return $this->_setDbError('mssql_connect()'); - $ok = @mssql_select_db(preg_replace('{^/}s', '', $p['path']), $this->link); + $ok = @mssql_select_db(preg_replace('{^/}s', '', $dsn['path']), $this->link); if (!$ok) return $this->_setDbError('mssql_select_db()'); } @@ -241,4 +241,3 @@ function length() return strlen($this->blobdata); } } -?> diff --git a/lib/DbSimple/Mypdo.php b/lib/DbSimple/Mypdo.php index 04c12d6..490bd51 100644 --- a/lib/DbSimple/Mypdo.php +++ b/lib/DbSimple/Mypdo.php @@ -15,7 +15,7 @@ * * @version 2.x $Id$ */ -require_once dirname(__FILE__).'/Database.php'; +require_once __DIR__.'/Database.php'; /** * Database class for MySQL. @@ -31,15 +31,57 @@ public function DbSimple_Mypdo($dsn) return $this->_setLastError("-1", "PDO extension is not loaded", "PDO"); try { - $this->link = new PDO('mysql:host='.$dsn['host'].(empty($dsn['port'])?'':';port='.$dsn['port']).';dbname='.$base, - $dsn['user'], isset($dsn['pass'])?$dsn['pass']:'', array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, - PDO::ATTR_PERSISTENT => isset($dsn['persist']) && $dsn['persist'], - PDO::ATTR_TIMEOUT => isset($dsn['timeout']) && $dsn['timeout'] ? $dsn['timeout'] : 0, - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES '.(isset($dsn['enc']) ? $dsn['enc'] : 'UTF8'), - )); + $options = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, + PDO::ATTR_PERSISTENT => isset($dsn['persist']) && $dsn['persist'], + PDO::ATTR_TIMEOUT => isset($dsn['timeout']) && $dsn['timeout'] ? $dsn['timeout'] : 0 + ); + + if (version_compare(PHP_VERSION, '5.3.6') < 0) { + $phpNew = false; + $options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . (!empty($dsn['enc']) ? $dsn['enc'] : 'utf8'); + } else { + $phpNew = true; + } + + if ( !empty($dsn['socket']) ) { + // Socket connection + + $dsnPdo = 'mysql:unix_socket=' . $dsn['socket'] + . ';dbname=' . $base; + + if ($phpNew) { + $dsnPdo .= ';charset=' . (!empty($dsn['enc']) ? $dsn['enc'] : 'utf8'); + } + + $this->link = new PDO( + $dsnPdo, + isset($dsn['user']) ? $dsn['user'] : 'root', + isset($dsn['pass']) ? $dsn['pass'] : '', + $options + ); + } else if ( !empty($dsn['host']) ) { + // Host connection + + $dsnPdo = 'mysql:host=' . $dsn['host'] + . (empty($dsn['port']) ? '' : ';port='.$dsn['port']) + . ';dbname=' . $base; + + if ($phpNew) { + $dsnPdo .= ';charset=' . (!empty($dsn['enc']) ? $dsn['enc'] : 'utf8'); + } + + $this->link = new PDO( + $dsnPdo, + $dsn['user'], + isset($dsn['pass']) ? $dsn['pass'] : '', + $options + ); + } else { + throw new Exception("Could not find hostname nor socket in DSN string"); + } } catch (PDOException $e) { - $this->_setLastError($e->getCode() , $e->getMessage(), 'new PDO'); + return $this->_setLastError($e->getCode() , $e->getMessage(), 'new PDO'); } } @@ -140,5 +182,3 @@ protected function _performFetch($result) } } - -?> \ No newline at end of file diff --git a/lib/DbSimple/Mysql.php b/lib/DbSimple/Mysql.php index 171ae62..45aeb07 100644 --- a/lib/DbSimple/Mysql.php +++ b/lib/DbSimple/Mysql.php @@ -16,7 +16,7 @@ * * @version 2.x $Id: Mysql.php 247 2008-08-18 21:17:08Z dk $ */ -require_once dirname(__FILE__).'/Database.php'; +require_once __DIR__.'/Database.php'; /** @@ -35,15 +35,24 @@ function DbSimple_Mysql($dsn) $connect = 'mysql_'.((isset($dsn['persist']) && $dsn['persist'])?'p':'').'connect'; if (!is_callable($connect)) return $this->_setLastError("-1", "MySQL extension is not loaded", $connect); + + //$mysql = mysql_connect(':/cloudsql/' . DB_HOST, DB_USER, DB_PASS); + + if ( !empty($dsn['socket']) && empty($dsn['host']) ) { + // Socket connection + $dsn['host'] = ':' . $dsn['socket']; + unset($dsn['port']); + } + $ok = $this->link = @call_user_func($connect, - $dsn['host'] . (empty($dsn['port'])? "" : ":".$dsn['port']), - empty($dsn['user'])?'':$dsn['user'], - empty($dsn['pass'])?'':$dsn['pass'], + $str = $dsn['host'] . (empty($dsn['port'])? "" : ":".$dsn['port']), + $dsn['user'] = empty($dsn['user'])?'':$dsn['user'], + $dsn['pass'] = empty($dsn['pass'])?'':$dsn['pass'], true ); $this->_resetLastError(); if (!$ok) - if (!$ok) return $this->_setDbError('mysql_connect("' . $str . '", "' . $p['user'] . '")'); + if (!$ok) return $this->_setDbError('mysql_connect("' . $str . '", "' . $dsn['user'] . '")'); $ok = @mysql_select_db(preg_replace('{^/}s', '', $dsn['path']), $this->link); if (!$ok) return $this->_setDbError('mysql_select_db()'); diff --git a/lib/DbSimple/Mysqli.php b/lib/DbSimple/Mysqli.php index 78b7d56..6d100e6 100644 --- a/lib/DbSimple/Mysqli.php +++ b/lib/DbSimple/Mysqli.php @@ -16,7 +16,7 @@ * * @version 2.x $Id: Mysqli.php 247 2008-08-18 21:17:08Z dk $ */ -require_once dirname(__FILE__).'/Database.php'; +require_once __DIR__.'/Database.php'; /** @@ -42,14 +42,30 @@ function DbSimple_Mysqli($dsn) } else { $dsn["host"] = "p:".$dsn["host"]; } - } - - $this->link = mysqli_connect( - $dsn['host'] . (empty($dsn['port'])? "" : ":".$dsn['port']), - empty($dsn['user'])?'':$dsn['user'], - empty($dsn['pass'])?'':$dsn['pass'], - preg_replace('{^/}s', '', $dsn['path']) - ); + } + + if ( isset($dsn['socket']) ) { + // Socket connection + $this->link = mysqli_connect( + null // host + ,empty($dsn['user']) ? 'root' : $dsn['user'] // user + ,empty($dsn['pass']) ? '' : $dsn['pass'] // password + ,preg_replace('{^/}s', '', $dsn['path']) // schema + ,null // port + ,$dsn['socket'] // socket + ); + } else if (isset($dsn['host']) ) { + // Host connection + $this->link = mysqli_connect( + $dsn['host'] + ,empty($dsn['user']) ? 'root' : $dsn['user'] + ,empty($dsn['pass']) ? '' : $dsn['pass'] + ,preg_replace('{^/}s', '', $dsn['path']) + ,empty($dsn['port']) ? null : $dsn['port'] + ); + } else { + return $this->_setDbError('mysqli_connect()'); + } $this->_resetLastError(); if (!$this->link) return $this->_setDbError('mysqli_connect()'); @@ -173,7 +189,7 @@ protected function _setDbError($query) if ($this->link) { return $this->_setLastError(mysqli_errno($this->link), mysqli_error($this->link), $query); } else { - return $this->_setLastError(mysqli_errno(), mysqli_error(), $query); + return $this->_setLastError(mysqli_connect_errno(), mysqli_connect_error(), $query); } } } @@ -213,4 +229,3 @@ public function length() return strlen($this->blobdata); } } -?> \ No newline at end of file diff --git a/lib/DbSimple/Postgresql.php b/lib/DbSimple/Postgresql.php index e1c8680..7fe4daf 100644 --- a/lib/DbSimple/Postgresql.php +++ b/lib/DbSimple/Postgresql.php @@ -16,7 +16,7 @@ * * @version 2.x $Id$ */ -require_once dirname(__FILE__) . '/Database.php'; +require_once __DIR__ . '/Database.php'; /** @@ -317,4 +317,3 @@ function _firstUse() return true; } } -?> \ No newline at end of file diff --git a/lib/DbSimple/Sqlite.php b/lib/DbSimple/Sqlite.php index a477233..f9d7d96 100644 --- a/lib/DbSimple/Sqlite.php +++ b/lib/DbSimple/Sqlite.php @@ -14,7 +14,7 @@ * * @version 2.x $Id$ */ -require_once dirname(__FILE__).'/Database.php'; +require_once __DIR__.'/Database.php'; /** * Database class for Sqlite. @@ -147,4 +147,3 @@ protected function _performFetch($result) } -?> \ No newline at end of file diff --git a/lib/DbSimple/Zend/Cache.php b/lib/DbSimple/Zend/Cache.php new file mode 100644 index 0000000..aff2e65 --- /dev/null +++ b/lib/DbSimple/Zend/Cache.php @@ -0,0 +1,250 @@ +setBackend($backendObject); + return $frontendObject; + } + + /** + * Backend Constructor + * + * @param string $backend + * @param array $backendOptions + * @param boolean $customBackendNaming + * @param boolean $autoload + * @return Zend_Cache_Backend + */ + public static function _makeBackend($backend, $backendOptions, $customBackendNaming = false, $autoload = false) + { + if (!$customBackendNaming) { + $backend = self::_normalizeName($backend); + } + if (in_array($backend, Zend_Cache::$standardBackends)) { + // we use a standard backend + $backendClass = 'Zend_Cache_Backend_' . $backend; + // security controls are explicit + require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php'; + } else { + // we use a custom backend + if (!preg_match('~^[\w\\\\]+$~D', $backend)) { + Zend_Cache::throwException("Invalid backend name [$backend]"); + } + if (!$customBackendNaming) { + // we use this boolean to avoid an API break + $backendClass = 'Zend_Cache_Backend_' . $backend; + } else { + $backendClass = $backend; + } + if (!$autoload) { + $file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php'; + if (!(self::_isReadable($file))) { + self::throwException("file $file not found in include_path"); + } + require_once $file; + } + } + return new $backendClass($backendOptions); + } + + /** + * Frontend Constructor + * + * @param string $frontend + * @param array $frontendOptions + * @param boolean $customFrontendNaming + * @param boolean $autoload + * @return Zend_Cache_Core|Zend_Cache_Frontend + */ + public static function _makeFrontend($frontend, $frontendOptions = array(), $customFrontendNaming = false, $autoload = false) + { + if (!$customFrontendNaming) { + $frontend = self::_normalizeName($frontend); + } + if (in_array($frontend, self::$standardFrontends)) { + // we use a standard frontend + // For perfs reasons, with frontend == 'Core', we can interact with the Core itself + $frontendClass = 'Zend_Cache_' . ($frontend != 'Core' ? 'Frontend_' : '') . $frontend; + // security controls are explicit + require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php'; + } else { + // we use a custom frontend + if (!preg_match('~^[\w\\\\]+$~D', $frontend)) { + Zend_Cache::throwException("Invalid frontend name [$frontend]"); + } + if (!$customFrontendNaming) { + // we use this boolean to avoid an API break + $frontendClass = 'Zend_Cache_Frontend_' . $frontend; + } else { + $frontendClass = $frontend; + } + if (!$autoload) { + $file = str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php'; + if (!(self::_isReadable($file))) { + self::throwException("file $file not found in include_path"); + } + require_once $file; + } + } + return new $frontendClass($frontendOptions); + } + + /** + * Throw an exception + * + * Note : for perf reasons, the "load" of Zend/Cache/Exception is dynamic + * @param string $msg Message for the exception + * @throws Zend_Cache_Exception + */ + public static function throwException($msg, Exception $e = null) + { + // For perfs reasons, we use this dynamic inclusion + require_once 'Zend/Cache/Exception.php'; + throw new Zend_Cache_Exception($msg, 0, $e); + } + + /** + * Normalize frontend and backend names to allow multiple words TitleCased + * + * @param string $name Name to normalize + * @return string + */ + protected static function _normalizeName($name) + { + $name = ucfirst(strtolower($name)); + $name = str_replace(array('-', '_', '.'), ' ', $name); + $name = ucwords($name); + $name = str_replace(' ', '', $name); + if (stripos($name, 'ZendServer') === 0) { + $name = 'ZendServer_' . substr($name, strlen('ZendServer')); + } + + return $name; + } + + /** + * Returns TRUE if the $filename is readable, or FALSE otherwise. + * This function uses the PHP include_path, where PHP's is_readable() + * does not. + * + * Note : this method comes from Zend_Loader (see #ZF-2891 for details) + * + * @param string $filename + * @return boolean + */ + private static function _isReadable($filename) + { + if (!$fh = @fopen($filename, 'r', true)) { + return false; + } + @fclose($fh); + return true; + } + +} diff --git a/lib/DbSimple/Zend/Cache/Backend/Interface.php b/lib/DbSimple/Zend/Cache/Backend/Interface.php new file mode 100644 index 0000000..3f44e2e --- /dev/null +++ b/lib/DbSimple/Zend/Cache/Backend/Interface.php @@ -0,0 +1,99 @@ + infinite lifetime) + * @return boolean true if no problem + */ + public function save($data, $id, $tags = array(), $specificLifetime = false); + + /** + * Remove a cache record + * + * @param string $id Cache id + * @return boolean True if no problem + */ + public function remove($id); + + /** + * Clean some cache records + * + * Available modes are : + * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) + * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} + * ($tags can be an array of strings or a single string) + * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags + * ($tags can be an array of strings or a single string) + * + * @param string $mode Clean mode + * @param array $tags Array of tags + * @return boolean true if no problem + */ + public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()); + +} diff --git a/lib/config.php b/lib/config.php index b9c5207..46cf1f9 100644 --- a/lib/config.php +++ b/lib/config.php @@ -2,5 +2,5 @@ // Подключается ко всем сценариям (автоматически или вручную) if (!defined("PATH_SEPARATOR")) define("PATH_SEPARATOR", getenv("COMSPEC")? ";" : ":"); -ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.dirname(__FILE__)); +ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.__DIR__); ?> \ No newline at end of file diff --git a/t/Cache/TstCacher.php b/t/Cache/TstCacher.php index efeff2d..68e0f9b 100644 --- a/t/Cache/TstCacher.php +++ b/t/Cache/TstCacher.php @@ -1,6 +1,6 @@ setCacher($Cacher = new TstCacher()); $query = " -- CACHE: 10 diff --git a/t/DbSimple/Generic/070_nested_blocks.phpt b/t/DbSimple/Generic/070_nested_blocks.phpt index c47a40b..4ee8dab 100644 --- a/t/DbSimple/Generic/070_nested_blocks.phpt +++ b/t/DbSimple/Generic/070_nested_blocks.phpt @@ -2,7 +2,7 @@ Generic: nested {}-blocks usage --FILE-- setCacher(new TstCacher()); $query = "-- CACHE: test.m SELECT * FROM test"; diff --git a/t/DbSimple/Generic/140_class_row.phpt b/t/DbSimple/Generic/140_class_row.phpt index 294f308..90ab38b 100644 --- a/t/DbSimple/Generic/140_class_row.phpt +++ b/t/DbSimple/Generic/140_class_row.phpt @@ -2,7 +2,7 @@ Generic: row class --FILE-- setIdentPrefix('as_'); $DB->setCachePrefix('db_'); - require_once dirname(__FILE__) . '/../../Cache/TstCacher.php'; + require_once __DIR__ . '/../../Cache/TstCacher.php'; $DB->setCacher($Cacher = new TstCacher()); $query = " -- CACHE: 10 diff --git a/t/DbSimple/Postgresql/005_connect_error.phpt b/t/DbSimple/Postgresql/005_connect_error.phpt index 78a9733..596180b 100644 --- a/t/DbSimple/Postgresql/005_connect_error.phpt +++ b/t/DbSimple/Postgresql/005_connect_error.phpt @@ -4,7 +4,7 @@ Postgresql: connection error catching --FILE--