yii\mongodb\ActiveRecord::collectionName PHP Метод

collectionName() публичный статический Метод

Collection name can be either a string or array: - if string considered as the name of the collection inside the default database. - if array - first element considered as the name of the database, second - as name of collection inside that database By default this method returns the class name as the collection name by calling [[Inflector::camel2id()]]. For example, 'Customer' becomes 'customer', and 'OrderItem' becomes 'order_item'. You may override this method if the collection is not named after this convention.
public static collectionName ( ) : string | array
Результат string | array the collection name
    public static function collectionName()
    {
        return Inflector::camel2id(StringHelper::basename(get_called_class()), '_');
    }

Usage Example

Пример #1
0
 /**
  * Returns a value indicating whether the given active record is the same as the current one.
  * The comparison is made by comparing the collection names and the primary key values of the two active records.
  * If one of the records [[isNewRecord|is new]] they are also considered not equal.
  * @param ActiveRecord $record record to compare to
  * @return boolean whether the two active records refer to the same row in the same Mongo collection.
  */
 public function equals($record)
 {
     if ($this->isNewRecord || $record->isNewRecord) {
         return false;
     }
     return $this->collectionName() === $record->collectionName() && (string) $this->getPrimaryKey() === (string) $record->getPrimaryKey();
 }