Beispiel #1
0
 /**
  * Initializes the migration.
  * This method will set {@see \rock\mongodb\Migration::$connection} to be the 'mongodb' application component, if it is null.
  */
 public function init()
 {
     $this->connection = Instance::ensure($this->connection, Connection::className());
 }
Beispiel #2
0
 /**
  * Returns the Mongo collection for this query.
  *
  * @param ConnectionInterface $connection Mongo connection.
  * @return Collection collection instance.
  */
 public function getCollection(ConnectionInterface $connection = null)
 {
     $this->connection = isset($connection) ? $connection : Instance::ensure($this->connection, Connection::className());
     $this->calculateCacheParams($this->connection);
     return $this->connection->getCollection($this->from);
 }
Beispiel #3
0
 /**
  * Returns the Mongo connection used by this AR class.
  * By default, the "mongodb" application component is used as the Mongo connection.
  * You may override this method if you want to use a different database connection.
  * @return Connection the database connection used by this AR class.
  */
 public static function getConnection()
 {
     return Instance::ensure('mongodb', Connection::className());
 }