Sokil\Mongo\Database::executeJS PHP Method

executeJS() public method

public executeJS ( $code, array $args = [] )
$args array
    public function executeJS($code, array $args = array())
    {
        $response = $this->getMongoDB()->execute($code, $args);
        if ($response['ok'] == 1.0) {
            return $response['retval'];
        } else {
            throw new Exception('Error #' . $response['code'] . ': ' . $response['errmsg'], $response['code']);
        }
    }

Usage Example

コード例 #1
0
ファイル: DatabaseTest.php プロジェクト: agolomazov/php-mongo
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Error #16722: exception: ReferenceError: gversion is not defined
  */
 public function testExecuteInvalidJs()
 {
     $this->database->executeJS('gversion()');
 }