Пример #1
0
        $objects = array();
        foreach ($cursor as $object) {
            $objects[] = $object;
        }
        return $objects;
    }
    /**
     * Save an Object in the DB
     * @param String $table
     * @param \App\Component\Model $object
     */
    public static function save($table, $object)
    {
        $collection = self::$database->{$table};
        $array = $object->toArray();
        $collection->save($array);
        $object->setId($array['_id']);
    }
    /**
     * Remove a given Object from the DB
     * @param String $table
     * @param \App\Component\Model $object
     */
    public static function delete($table, $object)
    {
        $collection = self::$database->{$table};
        $collection->remove($object->toArray());
    }
}
Database::setInstance();