本文整理匯總了PHP中Zend\Db\Sql\Select::quantifier方法的典型用法代碼示例。如果您正苦於以下問題:PHP Select::quantifier方法的具體用法?PHP Select::quantifier怎麽用?PHP Select::quantifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Db\Sql\Select
的用法示例。
在下文中一共展示了Select::quantifier方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testQuantifier
/**
* @testdox unit test: Test quantifier() returns Select object (is chainable)
* @covers Zend\Db\Sql\Select::quantifier
*/
public function testQuantifier()
{
$select = new Select();
$return = $select->quantifier($select::QUANTIFIER_DISTINCT);
$this->assertSame($select, $return);
return $return;
}
示例2: getColumns
/**
* @inheritDoc
*/
public function getColumns($tableName, $params = null)
{
$zendDb = Bootstrap::get('zendDb');
$acl = Bootstrap::get('acl');
$blacklist = $readFieldBlacklist = $acl->getTablePrivilegeList($tableName, $acl::FIELD_READ_BLACKLIST);
$columnName = isset($params['column_name']) ? $params['column_name'] : -1;
$selectOne = new Select();
$selectOne->quantifier($selectOne::QUANTIFIER_DISTINCT);
$selectOne->columns(['id' => 'COLUMN_NAME', 'column_name' => 'COLUMN_NAME', 'type' => new Expression('UCASE(C.DATA_TYPE)'), 'char_length' => 'CHARACTER_MAXIMUM_LENGTH', 'is_nullable' => 'IS_NULLABLE', 'default_value' => 'COLUMN_DEFAULT', 'comment' => new Expression('IFNULL(comment, COLUMN_COMMENT)'), 'sort' => new Expression('IFNULL(sort, ORDINAL_POSITION)'), 'column_type' => 'COLUMN_TYPE']);
$selectOne->from(['C' => new TableIdentifier('COLUMNS', 'INFORMATION_SCHEMA')]);
$selectOne->join(['D' => 'directus_columns'], 'C.COLUMN_NAME = D.column_name AND C.TABLE_NAME = D.table_name', ['ui', 'hidden_list' => new Expression('IFNULL(hidden_list, 0)'), 'hidden_input' => new Expression('IFNULL(hidden_input, 0)'), 'relationship_type', 'related_table', 'junction_table', 'junction_key_left', 'junction_key_right', 'required' => new Expression('IFNULL(D.required, 0)')], $selectOne::JOIN_LEFT);
$where = new Where();
$where->equalTo('C.TABLE_SCHEMA', $zendDb->getCurrentSchema())->equalTo('C.TABLE_NAME', $tableName)->nest()->addPredicate(new \Zend\Db\Sql\Predicate\Expression('"' . $columnName . '" = -1'))->OR->equalTo('C.column_name', $columnName)->unnest();
if (count($blacklist)) {
$where->addPredicate(new NotIn('C.COLUMN_NAME', $blacklist));
}
$selectOne->where($where);
$selectTwo = new Select();
$selectTwo->columns(['id' => 'column_name', 'column_name', 'type' => new Expression('UCASE(data_type)'), 'char_length' => new Expression('NULL'), 'is_nullable' => new Expression('"NO"'), 'default_value' => new Expression('NULL'), 'comment', 'sort', 'column_type' => new Expression('NULL'), 'ui', 'hidden_list', 'hidden_input', 'relationship_type', 'related_table', 'junction_table', 'junction_key_left', 'junction_key_right', 'required' => new Expression('IFNULL(required, 0)')]);
$selectTwo->from('directus_columns');
$where = new Where();
$where->equalTo('TABLE_NAME', $tableName)->addPredicate(new In('data_type', ['alias', 'MANYTOMANY', 'ONETOMANY']))->nest()->addPredicate(new \Zend\Db\Sql\Predicate\Expression('"' . $columnName . '" = -1'))->OR->equalTo('column_name', $columnName)->unnest()->addPredicate(new IsNotNull('relationship_type'));
if (count($blacklist)) {
$where->addPredicate(new NotIn('COLUMN_NAME', $blacklist));
}
$selectTwo->where($where);
$selectTwo->order('sort');
$selectOne->combine($selectTwo);
$sql = new Sql($zendDb);
$statement = $sql->prepareStatementForSqlObject($selectOne);
$result = $statement->execute();
return iterator_to_array($result);
}
示例3: assignOptions
/**
*
* @param Select $select
* @param Options $options
* @return Select
*/
protected function assignOptions(Select $select, Options $options)
{
if ($options->hasLimit()) {
$select->limit($options->getLimit());
if ($options->hasOffset()) {
$select->offset($options->getOffset());
}
$select->quantifier(new Expression('SQL_CALC_FOUND_ROWS'));
}
return $select;
}