Permalink
Browse files

Merge pull request #6 from silverstripe-labs/master

File.ShowInFile
  • Loading branch information...
2 parents 0dfbf53 + 294c0d5 commit ea543efef7be779d5ddf4f561d4b215367a7a1b8 @smindel committed Sep 18, 2011
Showing with 60 additions and 54 deletions.
  1. +60 −54 code/SQLite3Database.php
View
@@ -871,7 +871,13 @@ public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $
}
// Always ensure that only pages with ShowInSearch = 1 can be searched
- $extraFilters['SiteTree'] .= " AND ShowInSearch <> 0";
+ $extraFilters['SiteTree'] .= ' AND ShowInSearch <> 0';
+ // File.ShowInSearch was added later, keep the database driver backwards compatible
+ // by checking for its existence first
+ $fields = $this->fieldList('File');
+ if(array_key_exists('ShowInSearch', $fields)) {
+ $extraFilters['File'] .= " AND ShowInSearch <> 0";
+ }
$limit = $start . ", " . (int) $pageLength;
@@ -939,7 +945,7 @@ public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $
* Does this database support transactions?
*/
public function supportsTransactions(){
- return version_compare($this->getVersion(), '3.6', '>=');
+ return version_compare($this->getVersion(), '3.6', '>=');
}
/*
@@ -953,24 +959,24 @@ public function supportsExtensions($extensions=Array('partitions', 'tablespaces'
return true;
elseif(isset($extensions['clustering']))
return true;
- else
- return false;
- }
-
- /**
- * @deprecated 1.2 use transactionStart() (method required for 2.4.x)
- */
- public function startTransaction($transaction_mode=false, $session_characteristics=false){
- $this->transactionStart($transaction_mode, $session_characteristics);
- }
-
- /*
- * Start a prepared transaction
- */
- public function transactionStart($transaction_mode=false, $session_characteristics=false){
- DB::query('BEGIN');
- }
-
+ else
+ return false;
+ }
+
+ /**
+ * @deprecated 1.2 use transactionStart() (method required for 2.4.x)
+ */
+ public function startTransaction($transaction_mode=false, $session_characteristics=false){
+ $this->transactionStart($transaction_mode, $session_characteristics);
+ }
+
+ /*
+ * Start a prepared transaction
+ */
+ public function transactionStart($transaction_mode=false, $session_characteristics=false){
+ DB::query('BEGIN');
+ }
+
/*
* Create a savepoint that you can jump back to if you encounter problems
*/
@@ -989,47 +995,47 @@ public function transactionRollback($savepoint=false){
DB::query("ROLLBACK TO $savepoint;");
} else {
DB::query('ROLLBACK;');
- }
- }
-
- /**
- * @deprecated 1.2 use transactionEnd() (method required for 2.4.x)
- */
- public function endTransaction(){
- $this->transactionEnd();
- }
-
- /*
- * Commit everything inside this transaction so far
- */
- public function transactionEnd(){
- DB::query('COMMIT;');
- }
-
- /**
- *
- * This is a stub function. Postgres caches the fieldlist results.
- *
- * @param string $tableName
- *
- * @return boolean
- */
- function clear_cached_fieldlist($tableName=false){
- return true;
- }
-
- /**
- * Convert a SQLQuery object into a SQL statement
- */
- public function sqlQueryToString(SQLQuery $sqlQuery) {
+ }
+ }
+
+ /**
+ * @deprecated 1.2 use transactionEnd() (method required for 2.4.x)
+ */
+ public function endTransaction(){
+ $this->transactionEnd();
+ }
+
+ /*
+ * Commit everything inside this transaction so far
+ */
+ public function transactionEnd(){
+ DB::query('COMMIT;');
+ }
+
+ /**
+ *
+ * This is a stub function. Postgres caches the fieldlist results.
+ *
+ * @param string $tableName
+ *
+ * @return boolean
+ */
+ function clear_cached_fieldlist($tableName=false){
+ return true;
+ }
+
+ /**
+ * Convert a SQLQuery object into a SQL statement
+ */
+ public function sqlQueryToString(SQLQuery $sqlQuery) {
if (!$sqlQuery->from) return '';
$distinct = $sqlQuery->distinct ? "DISTINCT " : "";
if($sqlQuery->delete) {
$text = "DELETE ";
} else if($sqlQuery->select) {
$text = "SELECT $distinct" . implode(", ", $sqlQuery->select);
}
- $text .= " FROM " . implode(" ", $sqlQuery->from);
+ if($sqlQuery->from) $text .= " FROM " . implode(" ", $sqlQuery->from);
if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->getFilter(). ")";
if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby);

0 comments on commit ea543ef

Please sign in to comment.