コード例 #1
0
ファイル: PipelineTest.php プロジェクト: agolomazov/php-mongo
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Aggregate error: some_error
  */
 public function testAggregate_ServerSideError()
 {
     $mongoDatabaseMock = $this->getMock('\\MongoDB', array('command'), array($this->collection->getDatabase()->getClient()->getMongoClient(), 'test'));
     $mongoDatabaseMock->expects($this->once())->method('command')->will($this->returnValue(array('ok' => (double) 0, 'errmsg' => 'some_error', 'code' => 1785342)));
     $database = new Database($this->collection->getDatabase()->getClient(), $mongoDatabaseMock);
     $database->getCollection('phpmongo_test_collection')->aggregate(array(array('$match' => array('field' => 'value'))));
 }
コード例 #2
0
ファイル: Queue.php プロジェクト: sokil/php-mongo
 public function __construct(Database $database, $channel)
 {
     $this->collection = $database->getCollection($channel)->disableDocumentPool();
 }
コード例 #3
0
ファイル: backend.php プロジェクト: noidexe/DropGal
    $retries = 0;
    //if autogal.lock there probably
    //another instance of the script
    //running. Give it some seconds
    //to finish
    while (file_exists('../../autogal.lock') && $retries < Config::max_retries) {
        //echo 'sleeping';
        sleep(1);
        $retries++;
    }
    //create a lock file so two
    //instances of the script don't
    //try to rebuild the galleries at
    //the same time
    try {
        $filelock = fopen('../../autogal.lock', 'w');
    } catch (Exception $e) {
        throw new Exeption('can\'t create autogal.lock');
    }
    $myDatabase = new Database();
    $myGenerator = new HTMLGenerator();
    $myDatabase->generateFromFile(Config::getDirURL());
    $myGenerator->generatePages($myDatabase->getCategories(), $myDatabase->getCollection());
    //Open autogal.lastmod and write the new hash of dir.txt
    $lastmod = fopen('../../autogal.lastmod', 'w');
    fwrite($lastmod, $dirhash);
    fclose($lastmod);
    fclose($filelock);
}
//Remove the lock
unlink('../../autogal.lock');