本文整理汇总了PHP中Object::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::execute方法的具体用法?PHP Object::execute怎么用?PHP Object::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::execute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_basic
/**
* Test basic usage of the command tester
*
* @return void
* @author Dan Cox
*/
public function test_basic()
{
$this->CT->execute('utility:main');
$this->assertContains('The main action', $this->CT->getOutput());
$this->assertInstanceOf('\\Danzabar\\CLI\\Application', $this->CT->getApplication());
$this->assertInstanceOf('\\UtilityTask', $this->CT->getTask());
}
示例2: query
/**
* Executes an SQL statement
* @param type $sql SQL query to execute
* @param type $params params for the query
*/
public function query($sql, $params = null)
{
if (isset($this->cfg->prefix)) {
$sql = str_replace('#__', $this->cfg->prefix, $sql);
}
$this->stmt = $this->instance->prepare($sql);
$this->stmt->execute($params);
$this->checkQuery();
}
示例3: test_helpFormat
/**
* Test the help list format is correct
*
* @return void
* @author Dan Cox
*/
public function test_helpFormat()
{
$this->CT->execute();
// Application Detail Assertions
$this->assertContains('Test CLI', $this->CT->getOutput());
$this->assertContains('version 1.0.0', $this->CT->getOutput());
// Random detail assertions
$this->assertContains('Help', $this->CT->getOutput());
$this->assertContains('Fake', $this->CT->getOutput());
$this->assertContains('confirmation', $this->CT->getOutput());
// Instruction Assertions
$this->assertContains('php [file] [command] [arguments] [options]', $this->CT->getOutput());
// Example commands Assertions
$this->assertContains('php [file] fake [params]', $this->CT->getOutput());
$this->assertContains('php [file] fake:askMe [params]', $this->CT->getOutput());
}
示例4: process
/**
* Exectutes a statement and calls the get_result method.
*
* @param Object $stmt : MySQLI query to be executed
**/
function process($stmt)
{
if (!$stmt->execute()) {
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
return $this->get_result($stmt);
}
示例5: test_table
/**
* Test the table drawing functionality.
*
* @return void
* @author Dan Cox
*/
public function test_table()
{
$this->CT->execute('utility:table');
$this->assertContains('Header1', $this->CT->getOutput());
$this->assertContains('Header2', $this->CT->getOutput());
}
示例6: test_acceptedExplicitConfirmation
/**
* Test the acceptance of the explicit confirmation
*
* @return void
* @author Dan Cox
*/
public function test_acceptedExplicitConfirmation()
{
$this->CT->setInput("yes\n");
$this->CT->execute('fake:explicitConfirm');
$this->assertContains("Confirmed", $this->CT->getOutput());
}
示例7: import
/**
* Store uploaded file to cache folder,
* fully manage error messages and ask for database insert
*
* @access public
* @return boolean
*/
public function import()
{
// Get file info
$file = $this->app->input->files->get('datasourceimport');
$tmpFile = $file['tmp_name'];
$tmpFileName = $file['name'];
try {
if (!$tmpFile || !$tmpFileName) {
throw new JMapException(JText::_('COM_JMAP_NOFILE_SELECTED'), 'error');
}
$tmpFileSize = $file['size'];
$allowedFileSize = 2 * 1024 * 1024;
// MB->Bytes
if ($tmpFileSize > $allowedFileSize) {
throw new JMapException(JText::_('COM_JMAP_SIZE_ERROR') . ' Max 2MB.', 'error');
}
$tmpFileExtension = @array_pop(explode('.', $tmpFileName));
if ($tmpFileExtension != 'json') {
throw new JMapException(JText::_('COM_JMAP_EXT_ERROR'), 'error');
}
// Deserialize contents
$fileContents = file_get_contents($tmpFile);
if ($fileContents) {
$objectToRestore = json_decode($fileContents);
}
if (!is_array($objectToRestore)) {
throw new JMapException(JText::_('COM_JMAP_INVALID_IMPORT_DATA'), 'error');
}
// Prepare the values array
$dbQueryArray = array();
foreach ($objectToRestore as $dataSource) {
// Check if the data source is of type plugin and if the plugin is installed, otherwise skip and warn user
if ($dataSource->type == 'plugin' && !JFolder::exists(JPATH_COMPONENT_ADMINISTRATOR . '/plugins/' . strtolower($dataSource->name))) {
$this->app->enqueueMessage(JText::sprintf('COM_JMAP_NOPLUGIN_INSTALLED_IMPORTED_DATASOURCE', $dataSource->name));
continue;
}
$dbSourceArray = array();
$dbSourceArray[] = $this->dbo->quote($dataSource->type);
$dbSourceArray[] = $this->dbo->quote(strip_tags($dataSource->name));
$dbSourceArray[] = $this->dbo->quote(strip_tags($dataSource->description));
$dbSourceArray[] = (int) $dataSource->published;
$dbSourceArray[] = $this->dbo->quote($dataSource->sqlquery);
$dbSourceArray[] = $this->dbo->quote($dataSource->sqlquery_managed);
$dbSourceArray[] = $this->dbo->quote($dataSource->params);
// Source imploded assignment
$dbQueryArray[] = implode(',', $dbSourceArray);
}
// Check if some valid data to import are available
if (!count($dbQueryArray)) {
throw new JMapException(JText::_('COM_JMAP_NO_IMPORT_DATA_FOUND'), 'warning');
}
// Final sources imploded assignment
$implodedSources = '(' . implode('),(', $dbQueryArray) . ')';
$queryImport = "INSERT INTO" . $this->dbo->quoteName('#__jmap') . "\n (" . "\n" . $this->dbo->quoteName('type') . "," . "\n" . $this->dbo->quoteName('name') . "," . "\n" . $this->dbo->quoteName('description') . "," . "\n" . $this->dbo->quoteName('published') . "," . "\n" . $this->dbo->quoteName('sqlquery') . "," . "\n" . $this->dbo->quoteName('sqlquery_managed') . "," . "\n" . $this->dbo->quoteName('params') . ")" . "\n VALUES " . $implodedSources;
$this->dbo->setQuery($queryImport);
$this->dbo->execute();
if ($this->dbo->getErrorNum()) {
throw new JMapException(JText::sprintf('COM_JMAP_DBERROR_IMPORT_DATA', $this->dbo->getErrorMsg()), 'error');
}
} catch (JMapException $e) {
$this->setError($e);
return false;
} catch (Exception $e) {
$jmapException = new JMapException($e->getMessage(), 'error');
$this->setError($jmapException);
return false;
}
return true;
}
示例8: test_exceptionOnFalseMultipleChoiceAnswers
/**
* Test that an exception is thrown on a mulitple choice question
*
* @return void
* @author Dan Cox
*/
public function test_exceptionOnFalseMultipleChoiceAnswers()
{
$this->CT->setInput("answer, fake\n");
$this->CT->execute("fake:multiChoice");
$this->assertContains("The answer you selected is invalid", $this->CT->getOutput());
}
示例9: purge
/**
* Runs the purge method on loaded fixtures
*
* @return void
* @author Dan Cox
*/
public function purge()
{
$this->executor->execute($this->loader, new ChainFilter(), Executor::PURGE);
}
示例10: test_intOptionFail
/**
* Same as above but a fail
*
* @return void
* @author Dan Cox
*/
public function test_intOptionFail()
{
$this->setExpectedException('Danzabar\\CLI\\Input\\Exceptions\\ValidationFailException');
$this->CT->execute('Input:intTest', array('int' => 'skjkd'));
}