本文整理汇总了PHP中static::collection方法的典型用法代码示例。如果您正苦于以下问题:PHP static::collection方法的具体用法?PHP static::collection怎么用?PHP static::collection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::collection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: distinctTags
/**
*
* @param array $types
* @return unknown
*/
public static function distinctTags($query = array())
{
$model = new static();
$distinct = $model->collection()->distinct("tags", $query);
$distinct = array_values(array_filter((array) $distinct));
return $distinct;
}
示例2: distinctPriorities
/**
*
* @param array $types
* @return unknown
*/
public static function distinctPriorities($query = array())
{
$model = new static();
$distinct = $model->collection()->distinct("priority", $query);
$distinct = array_values(array_filter($distinct));
sort($distinct);
return $distinct;
}
示例3: collection
/**
* Get the Collection from the Repository.
*
* @param Repository $repository A specific Repository to get the Collection from.
*
* @return Collection The Collection from the Repository.
*/
public static function collection(Repository $repository = null)
{
if (null === $repository) {
$repository = Tacit::getInstance()->container->get('repository');
}
static::$collection = $repository->collection(static::collectionName());
return static::$collection;
}
示例4: fromCode
public static function fromCode($isocode, $type = 'isocode_2')
{
$model = new static();
if ($doc = $model->collection()->findOne(array($type => $isocode))) {
$model = $model->bind($doc);
}
return $model;
}
示例5: getCollection
/**
* Provides direct access to the collection of temporaries, if necessary.
*/
public static function getCollection()
{
if (!static::$collection) {
static::$collection = new Collection();
register_shutdown_function(function () {
static::complete();
});
}
return static::$collection;
}
示例6: getCollection
/**
* Provides direct access to the collection of temporaries, if necessary.
*/
public static function getCollection()
{
if (!static::$collection) {
static::$collection = \Robo\Robo::getContainer()->get('collection');
register_shutdown_function(function () {
static::complete();
});
}
return static::$collection;
}
示例7: forSelection
/**
* Helper method for creating select list options
*
* @param array $query
* @return multitype:multitype:string NULL
*/
public static function forSelection(array $query = array(), $id_field = '_id')
{
$model = new static();
$cursor = $model->collection()->find($query, array("last_name" => 1, "first_name" => 1, "email" => 1));
$cursor->sort(array("last_name" => 1, "first_name" => 1));
$result = array();
foreach ($cursor as $doc) {
$array = array('id' => (string) $doc[$id_field], 'text' => htmlspecialchars(trim($doc['first_name'] . ' ' . $doc['last_name'] . ': ' . $doc['email']), ENT_QUOTES));
$result[] = $array;
}
return $result;
}
示例8: forSelection
/**
* Helper method for creating select list options
*
* @param array $query
* @return multitype:multitype:string NULL
*/
public static function forSelection(array $query = array())
{
$model = new static();
$cursor = $model->collection()->find($query, array($model->__select2_fields['text'] => 1));
$cursor->sort(array($model->__select2_fields['text'] => 1));
$result = array();
foreach ($cursor as $doc) {
$array = array('id' => (string) $doc[$model->__select2_fields['id']], 'text' => htmlspecialchars($doc[$model->__select2_fields['text']], ENT_QUOTES));
$result[] = $array;
}
return $result;
}
示例9: getCollection
protected function getCollection()
{
if (null === static::$collection) {
// connect
static::$client = new \MongoClient();
// select a database
static::$db = static::$client->ik2;
// select a collection (analogous to a relational database's table)
static::$collection = static::$db->cronario_jobsss2;
}
return static::$collection;
}
示例10: forSelection
/**
* Helper method for creating select list options
*
* @param array $query
* @return multitype:multitype:string NULL
*/
public static function forSelection(array $query = array())
{
$model = new static();
if (!isset($model->__select2_fields['brackets'])) {
$model->__select2_fields['brackets'] = '';
}
if (empty($model->__select2_fields['brackets'])) {
$cursor = $model->collection()->find($query, [$model->__select2_fields['text'] => 1, $model->__select2_fields['id'] => 1, $model->__select2_fields['slug'] => 1]);
} else {
$cursor = $model->collection()->find($query, [$model->__select2_fields['text'] => 1, $model->__select2_fields['id'] => 1, $model->__select2_fields['slug'] => 1, $model->__select2_fields['brackets'] => 1]);
}
$cursor->sort(array($model->__select2_fields['text'] => 1));
$result = array();
foreach ($cursor as $doc) {
$arr = [];
if (empty($model->__select2_fields['brackets'])) {
$arr = ['id' => (string) $doc[$model->__select2_fields['id']], 'text' => htmlspecialchars($doc[$model->__select2_fields['text']], ENT_QUOTES)];
} else {
$arr = ['id' => (string) $doc[$model->__select2_fields['id']], 'text' => htmlspecialchars($doc[$model->__select2_fields['text']], ENT_QUOTES) . ' (' . htmlspecialchars($doc[$model->__select2_fields['brackets']], ENT_QUOTES) . ')'];
}
$result[] = $arr;
}
return $result;
}
示例11: distinctActorTypes
/**
*
* @param unknown $query
* @return unknown
*/
public static function distinctActorTypes($query = array())
{
$model = new static();
$distinct = $model->collection()->distinct("actor_type", $query ? $query : null);
$distinct = array_values(array_filter($distinct));
sort($distinct);
return $distinct;
}
示例12: __construct
public function __construct($connection = null)
{
if ($connection !== null) {
$this->connection = $connection;
}
if (is_string($this->connection)) {
$this->connection = new Mongo($this->connection);
}
if (is_null(self::$collection)) {
static::$collection = Inflector::lower(get_called_class());
}
}
示例13: setCollection
/**
* PluginCollection을 지정한다.
*
* @param PluginCollection $collection plugin collection
*
* @return void
*/
public static function setCollection($collection)
{
static::$collection = $collection;
}
示例14: distinctStores
/**
*
* @param array $types
* @return unknown
*/
public static function distinctStores($query = null)
{
$model = new static();
$distinct = $model->collection()->distinct("storage", $query);
$distinct = array_values(array_filter($distinct));
return $distinct;
}
示例15: __construct
/**
* Set up class
*
* @return void
*/
public function __construct($collection = null)
{
static::$collection = !is_null($collection) ? $collection : new FormatCollection();
}