schema() public method

Builds an array of keyed on the fully-namespaced Model with array of fields as values for the given Query
public schema ( Query $query, Result | null $resource = null, object | null $context = null ) : array
$query lithium\data\model\Query A Query instance.
$resource Result | null An optional a result resource.
$context object | null
return array
示例#1
0
 public function schema($query, $resource = null, $context = null)
 {
     if (isset($this->return['schema'])) {
         return $this->return['schema'];
     }
     return parent::schema($query, $resource = null, $context = null);
 }
示例#2
0
文件: Sqlite3.php 项目: niel/lithium
	/**
	 * 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->numColumns();

		for ($i = 0; $i < $count; $i++) {
			$result[] = $resource->columnName($i);
		}
		return $result;
	}
示例#3
0
 /**
  * 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 = mysql_num_fields($resource->resource());
     for ($i = 0; $i < $count; $i++) {
         $result[] = mysql_field_name($resource->resource(), $i);
     }
     return $result;
 }
示例#4
0
 /**
  * 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;
 }