enabled LOCATE() function and removed destructor from shutdown_hook

git-svn-id: https://plugins.svn.wordpress.org/sqlite-integration/trunk@745484 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
kjmtsh 2013-07-24 06:47:44 +00:00
parent 9322343898
commit 2f53a02728
5 changed files with 52 additions and 6 deletions

View File

@ -56,7 +56,8 @@ class PDOSQLiteUDFS {
'lcase' => 'lcase', 'lcase' => 'lcase',
'inet_ntoa' => 'inet_ntoa', 'inet_ntoa' => 'inet_ntoa',
'inet_aton' => 'inet_aton', 'inet_aton' => 'inet_aton',
'datediff' => 'datediff' 'datediff' => 'datediff',
'locate' => 'locate'
); );
public function month($field){ public function month($field){
@ -366,5 +367,23 @@ class PDOSQLiteUDFS {
$interval = floor(($end_date - $start_date)/(3600*24)); $interval = floor(($end_date - $start_date)/(3600*24));
return $interval; 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;
}
}
}
} }
?> ?>

View File

@ -57,7 +57,8 @@ class PDOSQLiteUDFS {
'lcase' => 'lcase', 'lcase' => 'lcase',
'inet_ntoa' => 'inet_ntoa', 'inet_ntoa' => 'inet_ntoa',
'inet_aton' => 'inet_aton', 'inet_aton' => 'inet_aton',
'datediff' => 'datediff' 'datediff' => 'datediff',
'locate' => 'locate'
); );
public function month($field){ public function month($field){
@ -340,5 +341,23 @@ class PDOSQLiteUDFS {
return $interval->format('%r%a'); 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;
}
}
}
} }
?> ?>

View File

@ -35,11 +35,9 @@ class PDOEngine extends PDO {
/** /**
* Constructor * Constructor
* registers __destruct function and initialize the database environment
* @param array $DatabaseParams * @param array $DatabaseParams
*/ */
function __construct() { function __construct() {
register_shutdown_function(array($this, '__destruct'));
$this->init(); $this->init();
} }
function __destruct() { function __destruct() {

View File

@ -7,7 +7,7 @@ Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/ Author URI: http://dogwood.skr.jp/
Requires at least: 3.3 Requires at least: 3.3
Tested up to: 3.5.2 Tested up to: 3.5.2
Stable tag: 1.0 Stable tag: 1.1
License: GPLv2 License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -162,6 +162,11 @@ wp-config.phpの準備が終わったら、次のステップに進みます。
== Changelog == == Changelog ==
= 1.1 (2013-07-24) =
* DROP INDEX 単独のクエリが動作していなかったのを修正しました。
* shutdown_hook で descructor を実行していたのをやめました。
* LOCATE() 関数を使えるようにしました。
= 1.0 (2013-07-07) = = 1.0 (2013-07-07) =
最初のリリース。 最初のリリース。

View File

@ -7,7 +7,7 @@ Author: Kojima Toshiyasu
Author URI: http://dogwood.skr.jp/ Author URI: http://dogwood.skr.jp/
Requires at least: 3.3 Requires at least: 3.3
Tested up to: 3.5.2 Tested up to: 3.5.2
Stable tag: 1.0 Stable tag: 1.1
License: GPLv2 License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -154,6 +154,11 @@ Probably there are more, I'm afraid.
== Changelog == == 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) = = 1.0 (2013-07-07) =
First release version of the plugin. First release version of the plugin.