当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::execute方法代码示例

本文整理汇总了PHP中Server::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::execute方法的具体用法?PHP Server::execute怎么用?PHP Server::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server::execute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runJobs

 /**
  * @return void
  */
 private function runJobs(array $jobs)
 {
     foreach ($jobs as $job) {
         if (is_string($job) && preg_match('#^(https?|local|remote):(.+)#', $job, $m)) {
             if ($m[1] === 'local') {
                 $out = @system($m[2], $code);
                 $err = $code !== 0;
             } elseif ($m[1] === 'remote') {
                 $out = $this->server->execute($m[2]);
                 $err = FALSE;
             } else {
                 $err = ($out = @file_get_contents($job)) === FALSE;
             }
             $this->logger->log("{$job}: {$out}");
             if ($err) {
                 throw new \RuntimeException("Error in job {$job}");
             }
         } elseif (is_callable($job)) {
             if ($job($this->server, $this->logger, $this) === FALSE) {
                 throw new \RuntimeException('Error in job');
             }
         } else {
             throw new \InvalidArgumentException("Invalid job {$job}.");
         }
     }
 }
开发者ID:hranicka,项目名称:dg-ftp-deployment,代码行数:29,代码来源:Deployer.php

示例2: runJobs

 /**
  * @param  array of string|callable
  * @return void
  */
 private function runJobs(array $jobs)
 {
     foreach ($jobs as $job) {
         if (is_string($job) && preg_match('#^(https?|local|remote):\\s*(.+)#', $job, $m)) {
             $out = $err = NULL;
             if ($m[1] === 'local') {
                 $out = @system($m[2], $code);
                 $err = $code !== 0 ? "exit code {$code}" : NULL;
             } elseif ($m[1] === 'remote') {
                 try {
                     $out = $this->server->execute($m[2]);
                 } catch (ServerException $e) {
                     $err = $e->getMessage() ?: 'unknown error';
                 }
             } else {
                 $out = Helpers::fetchUrl($job, $err);
             }
             $this->logger->log($job . ($out == NULL ? '' : ": {$out}"));
             // intentionally ==
             if ($err) {
                 throw new \RuntimeException('Job failed, ' . $err);
             }
         } elseif (is_callable($job)) {
             if ($job($this->server, $this->logger, $this) === FALSE) {
                 throw new \RuntimeException('Job failed');
             }
         } else {
             throw new \InvalidArgumentException("Invalid job {$job}.");
         }
     }
 }
开发者ID:dg,项目名称:ftp-deployment,代码行数:35,代码来源:Deployer.php

示例3: runJobs

 /**
  * @param  array of string|callable
  * @return void
  */
 private function runJobs(array $jobs)
 {
     foreach ($jobs as $job) {
         if (is_string($job) && preg_match('#^(https?|local|remote):\\s*(.+)#', $job, $m)) {
             if ($m[1] === 'local') {
                 $out = @system($m[2], $code);
                 $err = $code !== 0;
             } elseif ($m[1] === 'remote') {
                 try {
                     $out = $this->server->execute($m[2]);
                 } catch (ServerException $e) {
                     $out = $e->getMessage();
                 }
                 $err = isset($e);
             } else {
                 $err = ($out = @file_get_contents($job)) === FALSE;
             }
             $this->logger->log($job . ($out == NULL ? '' : ": {$out}"));
             // intentionally ==
             if ($err) {
                 throw new \RuntimeException('Error in job');
             }
         } elseif (is_callable($job)) {
             if ($job($this->server, $this->logger, $this) === FALSE) {
                 throw new \RuntimeException('Error in job');
             }
         } else {
             throw new \InvalidArgumentException("Invalid job {$job}.");
         }
     }
 }
开发者ID:rebendajirijr,项目名称:ftp-deployment,代码行数:35,代码来源:Deployer.php

示例4: testInsertUpdateDelete

 public function testInsertUpdateDelete()
 {
     $select = 'SELECT query_id, param_1, param_2, param_3, result ' . 'FROM test_queries WHERE query_id = ?';
     $this->assertTrue($this->stmt->prepare($select));
     $this->stmt->organizeParams(array(99));
     $this->assertTrue($this->stmt->execute());
     $this->stmt->organizeResults();
     $expected = array();
     $this->assertEquals($expected, $this->stmt->fetch());
     $insert = 'INSERT INTO test_queries ' . '(query_id, param_1, param_2, param_3, result) ' . 'VALUES (?, ?, ?, ?, ?) ';
     $values = array(99, 88, 'code_z', 0, 'query 99 issued');
     $this->stmt->reset();
     $this->stmt->prepare($insert);
     $this->stmt->organizeParams($values);
     $this->assertTrue($this->stmt->execute());
     $this->stmt->reset();
     $this->assertTrue($this->stmt->prepare($select));
     $this->stmt->organizeParams(array(99));
     $this->assertTrue($this->stmt->execute());
     $this->stmt->organizeResults();
     $result = $this->stmt->fetch();
     $expected = array(array('query_id' => 99, 'param_1' => 88, 'param_2' => 'code_z', 'param_3' => 0, 'result' => 'query 99 issued'));
     $this->assertEquals($expected, $result);
     $update = 'Update test_queries ' . 'SET    param_1=?, param_2=?, param_3=?, result=? ' . 'WHERE  query_id = ?';
     $values = array(22, 'code_bbc', 1, 'update query passed', 99);
     $this->stmt->reset();
     $this->assertTrue($this->stmt->prepare($update));
     $this->stmt->organizeParams($values);
     $this->assertTrue($this->stmt->execute());
     $this->stmt->reset();
     $this->assertTrue($this->stmt->prepare($select));
     $this->stmt->organizeParams(array(99));
     $this->assertTrue($this->stmt->execute());
     $this->stmt->organizeResults();
     $result = $this->stmt->fetch();
     $expected = array(array('query_id' => 99, 'param_1' => 22, 'param_2' => 'code_bbc', 'param_3' => 1, 'result' => 'update query passed'));
     $this->assertEquals($expected, $result);
     $delete = 'DELETE FROM test_queries WHERE query_id = ?';
     $this->stmt->reset();
     $this->assertTrue($this->stmt->prepare($delete));
     $this->stmt->organizeParams(array(99));
     $this->assertTrue($this->stmt->execute());
     $this->assertTrue($this->stmt->prepare($select));
     $this->stmt->organizeParams(array(99));
     $this->assertTrue($this->stmt->execute());
     $this->stmt->organizeResults();
     $expected = array();
     $this->assertEquals($expected, $this->stmt->fetch());
     $this->stmt->close();
 }
开发者ID:kevinlondon,项目名称:appfuel,代码行数:50,代码来源:OperationsTest.php

示例5: testFetchBufferedResults

 /**
  * @dataProvider	provideBasicSql 
  * @return	null
  */
 public function testFetchBufferedResults($sql, $values)
 {
     $this->stmt->prepare($sql);
     $this->stmt->isPrepared();
     $params = $this->stmt->normalizeParams($values);
     $this->stmt->bindParams($params);
     $this->stmt->execute();
     $this->stmt->organizeResults();
     $ok = $this->stmt->storeResults();
     $results = $this->stmt->fetch();
     $this->stmt->freeStoredResults();
     $this->assertInternalType('array', $results);
     $expected = array(array('query_id' => 1, 'param_1' => 1, 'param_2' => 'code_a', 'param_3' => 0, 'result' => 'query issued'));
     $this->assertEquals($expected, $results);
 }
开发者ID:kevinlondon,项目名称:appfuel,代码行数:19,代码来源:StmtTest.php

示例6: execute

 public function execute()
 {
     // Parse payload
     if (empty($this->payload)) {
         $this->payload = file_get_contents('php://input');
     }
     if (is_string($this->payload)) {
         $this->payload = json_decode($this->payload, true);
     }
     // Check JSON format
     if (!is_array($this->payload)) {
         return $this->getResponse(array('error' => array('code' => -32700, 'message' => 'Parse error')), array('id' => null));
     }
     // Handle batch request
     if (array_keys($this->payload) === range(0, count($this->payload) - 1)) {
         $responses = array();
         foreach ($this->payload as $payload) {
             if (!is_array($payload)) {
                 $responses[] = $this->getResponse(array('error' => array('code' => -32600, 'message' => 'Invalid Request')), array('id' => null));
             } else {
                 $server = new Server($payload);
                 $response = $server->execute();
                 if ($response) {
                     $responses[] = $response;
                 }
             }
         }
         return empty($responses) ? '' : '[' . implode(',', $responses) . ']';
     }
     // Check JSON-RPC format
     if (!isset($this->payload['jsonrpc']) || !isset($this->payload['method']) || !is_string($this->payload['method']) || $this->payload['jsonrpc'] !== '2.0' || isset($this->payload['params']) && !is_array($this->payload['params'])) {
         return $this->getResponse(array('error' => array('code' => -32600, 'message' => 'Invalid Request')), array('id' => null));
     }
     // Procedure not found
     if (!isset(self::$procedures[$this->payload['method']])) {
         return $this->getResponse(array('error' => array('code' => -32601, 'message' => 'Method not found')), $this->payload);
     }
     $callback = self::$procedures[$this->payload['method']];
     $params = array();
     $reflection = new \ReflectionFunction($callback);
     if (isset($this->payload['params'])) {
         $parameters = $reflection->getParameters();
         if (!$this->mapParameters($this->payload['params'], $parameters, $params)) {
             return $this->getResponse(array('error' => array('code' => -32602, 'message' => 'Invalid params')), $this->payload);
         }
     }
     $result = $reflection->invokeArgs($params);
     return $this->getResponse(array('result' => $result), $this->payload);
 }
开发者ID:smagghe,项目名称:phpMyDomo,代码行数:49,代码来源:Server.php

示例7: handleBatchRequest

 /**
  * Handle batch request
  *
  * @access private
  * @return string
  */
 private function handleBatchRequest()
 {
     $responses = array();
     foreach ($this->payload as $payload) {
         if (!is_array($payload)) {
             $responses[] = $this->getResponse(array('error' => array('code' => -32600, 'message' => 'Invalid Request')), array('id' => null));
         } else {
             $server = new Server($payload, $this->callbacks, $this->classes);
             $response = $server->execute();
             if ($response) {
                 $responses[] = $response;
             }
         }
     }
     return empty($responses) ? '' : '[' . implode(',', $responses) . ']';
 }
开发者ID:zhangjingpu,项目名称:yaf-lib,代码行数:22,代码来源:Server.php


注:本文中的Server::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。