kjdev / php-ext-unqlite

UnQLite Extension for PHP
MIT License
34 stars 6 forks source link

Error Accessing Collection that Does Not Exist #2

Open c1moore opened 8 years ago

c1moore commented 8 years ago

When attempting to access a collection that does not exist, PHP throws an uncaught error shown below:

</b>Fatal error:</b> Uncaught exception 'UnQLite\Exception' with message 'unable to init UnQLite\Doc' in ...:30
stack trace:
#0 /.../*.php(30): UnQLite\DB-&gt;doc('nonExistentCollection')
#1 {main}

Is there any method to determine if a collection exists before trying to access the collection? Or can you instead return an error if the collection does not exist?

kjdev commented 8 years ago

What running source?

<?php
namespace UnQLite;

$db = new DB('test.db');
var_dump($db);

$doc = $db->doc('test-1');
var_dump($doc);

// output:
/*
object(UnQLite\DB)#1 (0) {
}
object(UnQLite\Doc)#2 (0) {
}
*/