* PDO-SQLite patches by nth

This commit is contained in:
Garvin Hicking 2010-10-12 12:38:13 +00:00
parent bf36e96f61
commit aba04f43b4
7 changed files with 11 additions and 21 deletions

View File

@ -3,6 +3,8 @@
Version 1.6 ()
------------------------------------------------------------------------
* PDO-SQLite patches by nth
* Fix newline before <?xml tag, thanks to deedw
* Only do '*' parameter expansion on the first page of search

View File

@ -73,7 +73,7 @@ if ($serendipity['GET']['adminAction'] == 'doDelete' && serendipity_checkFormTok
$remaining_cat = (int)$serendipity['POST']['cat']['remaining_catid'];
$category_ranges = serendipity_fetchCategoryRange((int)$serendipity['GET']['cid']);
$category_range = implode(' AND ', $category_ranges);
if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3') {
if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'pdo-sqlite') {
$query = "UPDATE {$serendipity['dbPrefix']}entrycat
SET categoryid={$remaining_cat} WHERE entryid IN
(

View File

@ -124,6 +124,7 @@ function serendipity_db_get_interval($val, $ival = 900) {
switch($serendipity['dbType']) {
case 'sqlite':
case 'sqlite3':
case 'pdo-sqlite':
$interval = $ival;
$ts = time();
break;

View File

@ -39,20 +39,7 @@ function serendipity_db_sqlite_fetch_array($row, $type = PDO::FETCH_BOTH)
$newrow[preg_replace('@^.+\.(.*)@', '\1', $i)] = str_replace($search, $replace, $v);
}
if ($type == PDO::FETCH_NUM)
$frow = array();
else
$frow = $newrow;
if ($type != PDO::FETCH_ASSOC) {
$i = 0;
foreach($newrow AS $k => $v) {
$frow[$i] = $v;
$i++;
}
}
return $frow;
return $newrow;
}
/**

View File

@ -770,7 +770,7 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
} else {
$cond['find_part'] = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')";
}
} elseif ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3') {
} elseif ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'pdo-sqlite') {
// Very extensive SQLite search. There currently seems no other way to perform fulltext search in SQLite
// But it's better than no search at all :-D
$term = str_replace('*', '%', $term);
@ -867,7 +867,7 @@ function &serendipity_searchEntries($term, $limit = '', $searchresults = '') {
//if * wasn't already appended and if there are none or not enough
//results, search again for entries containing the searchterm as a part
if ($p == 1 && strpos($term, '*') === false && $serendipity['dbType'] != 'sqlite' && $serendipity['dbType'] != 'sqlite3') {
if ($p == 1 && strpos($term, '*') === false && $serendipity['dbType'] != 'sqlite' && $serendipity['dbType'] != 'sqlite3' && $serendipity['dbType'] != 'pdo-sqlite') {
if (! is_array($search)) {
return serendipity_searchEntries($term.'*', $orig_limit);
}else if (count($search) < 4){
@ -951,7 +951,7 @@ function serendipity_getTotalEntries() {
global $serendipity;
// The unique query condition was built previously in serendipity_fetchEntries()
if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3') {
if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'pdo-sqlite') {
$querystring = "SELECT count(e.id) {$serendipity['fullCountQuery']} GROUP BY e.id";
} else {
$querystring = "SELECT count(distinct e.id) {$serendipity['fullCountQuery']}";
@ -960,7 +960,7 @@ function serendipity_getTotalEntries() {
$query =& serendipity_db_query($querystring);
if (is_array($query) && isset($query[0])) {
if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3') {
if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'pdo-sqlite') {
return count($query);
} else {
return $query[0][0];

View File

@ -742,7 +742,7 @@ function serendipity_checkInstallation() {
$errs[] = sprintf(CANT_EXECUTE_BINARY, 'convert imagemagick');
}
if ($_POST['dbType'] == 'sqlite' || $_POST['dbType'] == 'sqlite3') {
if ($_POST['dbType'] == 'sqlite' || $_POST['dbType'] == 'sqlite3' || $_POST['dbType'] == 'pdo-sqlite') {
// We don't want that our SQLite db file can be guessed from other applications on a server
// and have access to our's. So we randomize the SQLite dbname.
$_POST['sqlitedbName'] = $_POST['dbName'] . '_' . md5(time());

View File

@ -236,7 +236,7 @@ class serendipity_plugin_statistics extends serendipity_plugin
$max = time();
$min = $max - (15 * 60);
if ($serendipity['dbType'] == 'sqlite') {
if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'pdo-sqlite') {
$max_ts = date('H:i', $max);
$min_ts = date('H:i', $min);
$q = "SELECT count(counter_id) AS currentvisitors FROM {$serendipity['dbPrefix']}visitors WHERE day LIKE '" . date('Y-m-d') . "' AND (time BETWEEN '$min_ts' AND '$max_ts')";