Example #1
0
    /**
     * @expectedException Exception
     */
    public function testViewWithNoDatabaseOption()
    {
        $type = CouchDBTestConstants::kUpdateType;
        $map = <<<FUNCTION
\t\tfunction(doc) 
\t\t{ 
\t\t\tif(doc.type == '{$type}')
\t\t\t{ 
\t\t\t\temit(doc._id, doc);
\t\t\t}
\t\t}
FUNCTION;
        $couchdb = new CouchDB();
        $couchdb->create_view('records/no_database_selected', $map);
    }
Example #2
0
 *    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 *    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 *    PURPOSE. See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 *    Author: Adam Venturella - aventurella@gmail.com
 *
 *    @package Sample 
 *    @author Adam Venturella <*****@*****.**>
 *    @copyright Copyright (C) 2009 Adam Venturella
 *    @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
 *
 **/
/**
 * Sample
 */
require 'couchdb/CouchDB.php';
$newdb = 'newdb';
$options = array('database' => $newdb);
$db = new CouchDB($options);
$map = <<<MAP
\tfunction(doc)
\t{
\t\tif(doc.type == 'category')
\t\t{
\t\t\temit(doc._id, doc);
\t\t}
\t}
MAP;
$db->create_view('myviews/categories', $map);
 *
 *    @package Sample 
 *    @author Adam Venturella <*****@*****.**>
 *    @copyright Copyright (C) 2009 Adam Venturella
 *    @license http://www.apache.org/licenses/LICENSE-2.0 Apache 2.0
 *
 **/
/**
 * Sample
 */
require 'couchdb/CouchDB.php';
$newdb = 'newdb';
$options = array('database' => $newdb);
$db = new CouchDB($options);
$map = <<<MAP
\t\tfunction(doc)
\t\t{
\t\t\tif(doc.type == 'category')
\t\t\t{
\t\t\t\temit(doc._id, 1);
\t\t\t}
\t\t}
MAP;
$reduce = <<<REDUCE
\tfunction(keys, values, rereduce)
\t{
\t\treturn sum(values);
\t}
REDUCE;
$db->create_view('myviews/categoriesCount', $map, $reduce);