static function getQuery(array $params = array(), Query $q = null) {
		$model_class = get_called_class();
		$query_class = class_exists($model_class . 'Query') ? $model_class . 'Query' : 'Dabl\\Query\\Query';

		$q = $q ? clone $q : new $query_class;

		$tablename = $q->getTable();
		if (!$tablename) {
			$tablename = static::getTableName();
			$q->setTable($tablename);
		}

		// If an alias has been set, use that for fully-qualified names, otherwise use the table name
		$alias = $q->getAlias();
		if (!$alias) {
			$alias = $tablename;
		}

		// filters
		foreach ($params as $key => &$param) {
			if (static::hasColumn($key)) {
				$column = static::normalizeColumnName($key);
				$q->add("$alias.$column", strtolower($param) === 'null' ? null : $param);
			}
		}

		// SortBy (alias of sort_by, deprecated)
		if (isset($params['SortBy']) && !isset($params['order_by'])) {
			$params['order_by'] = $params['SortBy'];
		}

		// order_by
		if (isset($params['order_by']) && static::hasColumn($params['order_by'])) {
			$q->orderBy($params['order_by'], isset($params['dir']) ? Query::DESC : Query::ASC);
		}

		// limit
		if (isset($params['limit'])) {
			$q->setLimit($params['limit']);
		}

		return $q;
	}
static function getQuery(array $params = array(), Query $q = null) {
		$model_class = get_called_class();
		$query_class = class_exists($model_class . 'Query') ? $model_class . 'Query' : 'Dabl\\Query\\Query';

		$q = $q ? clone $q : new $query_class;

		$tablename = $q->getTable();
		if (!$tablename) {
			$tablename = static::getTableName();
			$q->setTable($tablename);
		}

		// If an alias has been set, use that for fully-qualified names, otherwise use the table name
		$alias = $q->getAlias();
		if (!$alias) {
			$alias = $tablename;
		}

		// filters
		foreach ($params as $key => &$param) {
			if (static::hasColumn($key)) {
				$column = static::normalizeColumnName($key);
				$q->add("$alias.$column", strtolower($param) === 'null' ? null : $param);
			}
		}

		// SortBy (alias of sort_by, deprecated)
		if (isset($params['SortBy']) && !isset($params['order_by'])) {
			$params['order_by'] = $params['SortBy'];
		}

		// order_by
		if (isset($params['order_by']) && static::hasColumn($params['order_by'])) {
			$q->orderBy($params['order_by'], isset($params['dir']) ? Query::DESC : Query::ASC);
		}

		// limit
		if (isset($params['limit'])) {
			$q->setLimit($params['limit']);
		}

		return $q;
	}
static function getQuery ( array $ params = array ( ) , Query $ q = null ) { $ model_class = get_called_class ( ) ; $ query_class = class_exists ( $ model_class . 'Query' ) ? $ model_class . 'Query' : 'Dabl\\Query\\Query' ; $ q = $ q ? clone $ q : new $ query_class ; $ tablename = $ q -> getTable ( ) ; if ( ! $ tablename ) { $ tablename = static :: getTableName ( ) ; $ q -> setTable ( $ tablename ) ; } // If an alias has been set, use that for fully-qualified names, otherwise use the table name $ alias = $ q -> getAlias ( ) ; if ( ! $ alias ) { $ alias = $ tablename ; } // filters foreach ( $ params as $ key => & $ param ) { if ( static :: hasColumn ( $ key ) ) { $ column = static :: normalizeColumnName ( $ key ) ; $ q -> add ( "$alias.$column" , strtolower ( $ param ) === 'null' ? null : $ param ) ; } } // SortBy (alias of sort_by, deprecated) if ( isset ( $ params [ 'SortBy' ] ) && ! isset ( $ params [ 'order_by' ] ) ) { $ params [ 'order_by' ] = $ params [ 'SortBy' ] ; } // order_by if ( isset ( $ params [ 'order_by' ] ) && static :: hasColumn ( $ params [ 'order_by' ] ) ) { $ q -> orderBy ( $ params [ 'order_by' ] , isset ( $ params [ 'dir' ] ) ? Query :: DESC : Query :: ASC ) ; } // limit if ( isset ( $ params [ 'limit' ] ) ) { $ q -> setLimit ( $ params [ 'limit' ] ) ; } return $ q ; }
Given an array of params, construct a query where the keys are used as column names
and values as query parameters. Will try to do fully-qualified names.
@return Query
Given an array of params construct a query where the keys are used as column names and values as query parameters . Will try to do fully - qualified names .