diff --git a/functions-5-2.php b/functions-5-2.php index 545b653..2399535 100644 --- a/functions-5-2.php +++ b/functions-5-2.php @@ -56,7 +56,8 @@ class PDOSQLiteUDFS { 'lcase' => 'lcase', 'inet_ntoa' => 'inet_ntoa', 'inet_aton' => 'inet_aton', - 'datediff' => 'datediff' + 'datediff' => 'datediff', + 'locate' => 'locate' ); public function month($field){ @@ -366,5 +367,23 @@ class PDOSQLiteUDFS { $interval = floor(($end_date - $start_date)/(3600*24)); return $interval; } + /** + * emulates MySQL LOCATE() function + */ + public function locate($substr, $str, $pos = 0) { + if (!extension_loaded('mbstring')) { + if (($val = stros($str, $substr, $pos)) !== false) { + return $val + 1; + } else { + return 0; + } + } else { + if (($val = mb_strpos($str, $substr, $pos)) !== false) { + return $val + 1; + } else { + return 0; + } + } + } } ?> \ No newline at end of file diff --git a/functions.php b/functions.php index 5f7af23..9caaf24 100644 --- a/functions.php +++ b/functions.php @@ -57,7 +57,8 @@ class PDOSQLiteUDFS { 'lcase' => 'lcase', 'inet_ntoa' => 'inet_ntoa', 'inet_aton' => 'inet_aton', - 'datediff' => 'datediff' + 'datediff' => 'datediff', + 'locate' => 'locate' ); public function month($field){ @@ -340,5 +341,23 @@ class PDOSQLiteUDFS { return $interval->format('%r%a'); } } + /** + * emulates MySQL LOCATE() function + */ + public function locate($substr, $str, $pos = 0) { + if (!extension_loaded('mbstring')) { + if (($val = stros($str, $substr, $pos)) !== false) { + return $val + 1; + } else { + return 0; + } + } else { + if (($val = mb_strpos($str, $substr, $pos)) !== false) { + return $val + 1; + } else { + return 0; + } + } + } } ?> \ No newline at end of file diff --git a/pdoengine.class.php b/pdoengine.class.php index 2e2521a..d12e9d2 100644 --- a/pdoengine.class.php +++ b/pdoengine.class.php @@ -35,11 +35,9 @@ class PDOEngine extends PDO { /** * Constructor - * registers __destruct function and initialize the database environment * @param array $DatabaseParams */ function __construct() { - register_shutdown_function(array($this, '__destruct')); $this->init(); } function __destruct() { diff --git a/readme-ja.txt b/readme-ja.txt index d8ceb27..5d7ca86 100644 --- a/readme-ja.txt +++ b/readme-ja.txt @@ -7,7 +7,7 @@ Author: Kojima Toshiyasu Author URI: http://dogwood.skr.jp/ Requires at least: 3.3 Tested up to: 3.5.2 -Stable tag: 1.0 +Stable tag: 1.1 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -162,6 +162,11 @@ wp-config.phpの準備が終わったら、次のステップに進みます。 == Changelog == += 1.1 (2013-07-24) = +* DROP INDEX 単独のクエリが動作していなかったのを修正しました。 +* shutdown_hook で descructor を実行していたのをやめました。 +* LOCATE() 関数を使えるようにしました。 + = 1.0 (2013-07-07) = 最初のリリース。 diff --git a/readme.txt b/readme.txt index 967e6d9..a00499a 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Author: Kojima Toshiyasu Author URI: http://dogwood.skr.jp/ Requires at least: 3.3 Tested up to: 3.5.2 -Stable tag: 1.0 +Stable tag: 1.1 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -154,6 +154,11 @@ Probably there are more, I'm afraid. == Changelog == += 1.1 (2013-07-24) = +* Fixed the manipulation of DROP INDEX query. +* Removed desctructor() from shutdown_hook. +* Enabled LOCATE() function in the query string. + = 1.0 (2013-07-07) = First release version of the plugin.