Permalink
Browse files

Move database adapter's `::schema()` to `data\source\Database`

  • Loading branch information...
1 parent 62b8b7a commit f7ffcce6d6f4ae7a44cce4d362e524170fd58d41 @jails jails committed Dec 17, 2012
View
@@ -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;
}
/**
@@ -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
@@ -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
@@ -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

0 comments on commit f7ffcce

Please sign in to comment.