Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #747 from jails/pr7

Move database adapter's `::schema()` to `data\source\Database`.
  • Loading branch information...
commit d09e3250f3555020470616264c2550d564f93844 2 parents 62b8b7a + f7ffcce
@gwoo gwoo authored
View
15 data/source/Database.php
@@ -672,8 +672,19 @@ public function renderCommand($type, $data = null, $context = null) {
* @param object $context
*/
public function schema($query, $resource = null, $context = null) {
- $query->applyStrategy($this);
- return $this->_schema($query, $this->_fields($query->fields(), $query));
+ if (is_object($query)) {
+ $query->applyStrategy($this);
+ return $this->_schema($query, $this->_fields($query->fields(), $query));
+ }
+
+ $result = array();
+ $count = $resource->resource()->columnCount();
+
+ for ($i = 0; $i < $count; $i++) {
+ $meta = $resource->resource()->getColumnMeta($i);
+ $result[] = $meta['name'];
+ }
+ return $result;
}
/**
View
24 data/source/database/adapter/MySql.php
@@ -231,30 +231,6 @@ public function value($value, array $schema = array()) {
}
/**
- * In cases where the query is a raw string (as opposed to a `Query` object), to database must
- * determine the correct column names from the result resource.
- *
- * @param mixed $query
- * @param resource $resource
- * @param object $context
- * @return array
- */
- public function schema($query, $resource = null, $context = null) {
- if (is_object($query)) {
- return parent::schema($query, $resource, $context);
- }
-
- $result = array();
- $count = $resource->resource()->columnCount();
-
- for ($i = 0; $i < $count; $i++) {
- $meta = $resource->resource()->getColumnMeta($i);
- $result[] = $meta['name'];
- }
- return $result;
- }
-
- /**
* Retrieves database error message and error code.
*
* @return array
View
24 data/source/database/adapter/PostgreSql.php
@@ -275,30 +275,6 @@ public function value($value, array $schema = array()) {
}
/**
- * In cases where the query is a raw string (as opposed to a `Query` object), to database must
- * determine the correct column names from the result resource.
- *
- * @param mixed $query
- * @param resource $resource
- * @param object $context
- * @return array
- */
- public function schema($query, $resource = null, $context = null) {
- if (is_object($query)) {
- return parent::schema($query, $resource, $context);
- }
-
- $result = array();
- $count = $resource->resource()->columnCount();
-
- for ($i = 0; $i < $count; $i++) {
- $meta = $resource->resource()->getColumnMeta($i);
- $result[] = $meta['name'];
- }
- return $result;
- }
-
- /**
* Retrieves database error message and error code.
*
* @return array
View
24 data/source/database/adapter/Sqlite3.php
@@ -238,30 +238,6 @@ public function encoding($encoding = null) {
}
/**
- * In cases where the query is a raw string (as opposed to a `Query` object), to database must
- * determine the correct column names from the result resource.
- *
- * @param mixed $query
- * @param resource $resource
- * @param object $context
- * @return object
- */
- public function schema($query, $resource = null, $context = null) {
- if (is_object($query)) {
- return parent::schema($query, $resource, $context);
- }
-
- $result = array();
- $count = $resource->resource()->columnCount();
-
- for ($i = 0; $i < $count; $i++) {
- $meta = $resource->resource()->getColumnMeta($i);
- $result[] = $meta['name'];
- }
- return $result;
- }
-
- /**
* Retrieves database error message and error code.
*
* @return array
Please sign in to comment.
Something went wrong with that request. Please try again.