コード例 #1
0
 /**
  * Returns collection object and assigns statically if not yet set.
  */
 public static function getCollection()
 {
     global $db;
     if (!self::$_collection) {
         if (!is_a($db, 'MongoDB')) {
             trigger_error("DBObjects rely on MongoDB connection", E_USER_ERROR);
         }
         $classname = get_called_class();
         if (!defined($classname . '::collectionName')) {
             throw new IncompleteImplementationException("Constant collectionName undefined in {$classname}");
         }
         self::$_collection = $db->selectCollection(constant($classname . '::collectionName'));
     }
     return self::$_collection;
 }