本文整理汇总了PHP中Queue::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::add方法的具体用法?PHP Queue::add怎么用?PHP Queue::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$command = array_shift($this->args);
$defaults = array('start' => null, 'end' => null, 'reschedule' => null, 'cpu' => null, 'cpu_limit' => null, 'priority' => 100);
$options = array_merge($defaults, (array) $this->params);
$options['cpu_limit'] = $options['cpu'];
$options = array_intersect_key($options, $defaults);
if (Queue::add($command, $this->params['type'], $options)) {
$this->out('Task succesfully added.', 1, Shell::QUIET);
$this->out(Queue::view($this->QueueTask->id));
} else {
$this->out('Error adding task.');
$this->out();
print_r($this->QueueTask->validationErrors);
}
}
示例2: saveQueue
function saveQueue($testbed, $suite)
{
$simple = new Queue();
$_GET['build'] = $_REQUEST['versionBuild'];
$_GET['suite'] = $suite;
$_GET['command'] = 1;
$_GET['testbed'] = $testbed;
$_GET['dbResults'] = "on";
$_GET['description'] = "Automatically queue'd from Nightly Build Server";
$_GET['userName'] = "nightly";
$_GET['tftpIP'] = 1;
$simple->setAuto($_GET);
$simple->setUid('');
$simple->load();
$simple->add();
sleep(6);
}
示例3: parse
public static function parse($item, $action)
{
$auth = Settings::getProtected('auth');
$auth->forceAuthentication();
$username = $auth->getUsername();
$user = new User($username);
// Parse the action
switch (trim($action)) {
case '@proofer':
$destinationQueue = "project.proof:" . $item->project_slug;
break;
case '@reviewer':
$destinationQueue = "project.review:" . $item->project_slug;
break;
default:
// username (defaults to proof, TODO: allow review as well)
$destinationQueue = "user.proof:" . $action;
break;
}
$queue = new Queue($destinationQueue);
$queue->add($item);
$queue->save();
}
示例4: createItems
public function createItems()
{
// Load the queue
$projectQueue = new Queue("project.proof:{$this->projectSlug}", false);
// Now go through the item info array
foreach ($this->itemData as $itemInfo) {
// Create a new item
$item = new Item();
// Populate it
$item->title = $itemInfo['title'];
$item->project_id = $itemInfo['project_id'];
$item->transcript = $itemInfo['transcript'];
$item->type = $itemInfo['type'];
$item->href = $itemInfo['href'];
// And add it to the database
$item->save();
// Save it to our $this->items array
array_push($this->items, $item);
// Add it to the queue
$projectQueue->add($item);
}
// Save the project queue
$projectQueue->save();
}
示例5: saveQueue
function saveQueue($testbed, $suite)
{
$linkID = mysql_connect('10.65.102.22', 'root', '123456');
if (!$linkID) {
die('Could not connect: ' . mysql_error());
}
$db = mysql_select_db('autoSmoke', $linkID);
$queryPrefix = "";
if ($_GET['prefix'] != "") {
$queryPrefix = "prefix = '" . $_GET['prefix'] . "' and ";
}
$threeMinAgo = date('Y-m-d H:i:s', mktime(date("H"), date("i") - 2, date("s"), date("n"), date("j"), date("Y")));
$sql = "select * " . "from " . "queue " . "where " . "userName='nightly' and " . "command regexp '1' and " . "description='Automatically queue\\'d from Nightly Build Server' and " . $queryPrefix . "testbed regexp '" . $testbed . "' and " . "build regexp '" . $_GET['versionBuild'] . "' and " . "suite = 'DD:" . $suite . "' and " . "status = 2 and '" . $threeMinAgo . "' <= creationDate";
$rs = mysql_query($sql);
if (!mysql_num_rows($rs)) {
$simple = new Queue();
if ($_GET['prefix'] == "C_" || $_GET['prefix'] == "T_") {
$_GET['prefix'] = $_GET[prefix];
}
$_GET['build'] = $_GET['versionBuild'];
$_GET['suite'] = $suite;
$_GET['command'] = 1;
$_GET['testbed'] = $testbed;
$_GET['dbResults'] = "on";
$_GET['description'] = "Automatically queue'd from Nightly Build Server";
$_GET['userName'] = "nightly";
$_GET['tftpIP'] = 1;
// if (!preg_match ("/^5.0/", $_GET['versionBuild']) && !preg_match ("/^6.0/", $_GET['versionBuild']))
// $_GET['loadAlcatel'] = 'on';
$simple->setAuto($_GET);
$simple->setUid('');
$simple->load();
$simple->add();
sleep(1);
}
mysql_close($linkID);
}
示例6: Queue
function test_All_Queries()
{
$value = "'Depeche Mode rocks!'";
$this->dbhandler->connect();
// create a new queue of queries to execuete
$queryQueue = new Queue();
$query = new InsertQuery();
$query->setTable("test1");
$query->setColumns(array("value"));
$query->addRowOfValues(array($value));
$queryQueue->add($query);
$query = new InsertQuery();
$query->setTable("test1");
$query->setColumns(array(id, value));
$query->addRowOfValues(array("3000000", $value));
$queryQueue->add($query);
$query = new DeleteQuery();
$query->setTable("test1");
$query->setWhere("id = 3000000");
$queryQueue->add($query);
$query = new UpdateQuery();
$query->setTable("test1");
$query->setColumns(array("value"));
$query->setValues(array($value));
$query->setWhere("id > 1000 AND id < 1006");
$queryQueue->add($query);
$resultQueue = $this->dbhandler->queryQueue($queryQueue);
$this->assertEqual($this->dbhandler->getTotalNumberOfQueries(), 4);
$this->assertEqual($this->dbhandler->getTotalNumberOfSuccessfulQueries(), 4);
$this->assertEqual($this->dbhandler->getTotalNumberOfFailedQueries(), 0);
$result = $resultQueue->next();
$this->assertEqual($result->getNumberOfRows(), 1);
$this->assertNotNull($result->getLastAutoIncrementValue());
$id = $result->getLastAutoIncrementValue();
$result = $resultQueue->next();
$this->assertEqual($result->getNumberOfRows(), 1);
$this->assertNotNull($result->getLastAutoIncrementValue());
$result = $resultQueue->next();
$this->assertEqual($result->getNumberOfRows(), 1);
$result = $resultQueue->next();
$query = new SelectQuery();
$query->setColumns(array("value"));
$query->addTable("test1");
$query->setWhere("id = {$id}");
$result = $this->dbhandler->query($query);
$this->assertEqual($this->dbhandler->getTotalNumberOfQueries(), 5);
$this->assertEqual($this->dbhandler->getTotalNumberOfSuccessfulQueries(), 5);
$this->assertEqual($this->dbhandler->getTotalNumberOfFailedQueries(), 0);
$this->assertEqual("'" . $result->field("value") . "'", $value);
$result->free();
}
示例7: add
/**
* Add a recipient to the queue
*
* @param string $email
* @param string $name
* @return Mail
*/
public function add($email, $name = null)
{
$this->queue->add($email, $name);
return $this;
}
示例8: queryQueue
/**
* Run a database query for each Query in the Queue and return a Queue of QueryResults.
* @param object QueueInterface A queue object which holds the queries to run.
* @param integer $dbIndex The index of the database on which to run the query. Default is 0, the database created on handler instantiation.
* @return object QueInterface Returns a Queue of QueryResults.
* @access public
*/
function queryQueue(Queue $queue, $dbIndex = 0)
{
if (isset($this->recordQueryCallers) && $this->recordQueryCallers) {
if (!isset($this->queryCallers)) {
$this->queryCallers = array();
}
$backtrace = debug_backtrace();
$this->queryCallers[] = $backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . "()";
}
// ** parameter validation
$this->_validateDBIndex($dbIndex);
// ** end of parameter validation
$resultQueue = new Queue();
while ($queue->hasNext()) {
$result = $this->_databases[$dbIndex]->query($queue->next());
$resultQueue->add($result);
}
return $resultQueue;
}
示例9: json_encode
try {
Queue::register('compare', array('Point', 'compareItems'));
Queue::register('destroy', 'destroyQueue');
} catch (Exception $e) {
echo "FAIL\n";
echo $e->getMessage();
}
$queue = new Queue('2');
echo "queue 1 loaded\n";
$item = $queue->getFirstItem();
echo 'first item: ' . $item . "\n";
$item = $queue->remove(new Point(4, 0));
echo 'fourth item: ' . $item . "\n";
$item = $queue->getFirstItem();
echo 'second item: ' . $item . "\n";
if ($queue->save()) {
echo "\nsaved.\n";
}
echo json_encode($queue->getItems());
echo "\n";
$items = $queue->getItems();
$items[] = new Point(4, 3);
$items[] = new Point(5, 3);
$items[] = new Point(1, 1);
$queue->setItems($items);
$queue->add(new Point(42, 222));
if ($queue->save()) {
echo "\nsaved.\n";
}
echo "test 2 done\n\n";
$queue->destroy();
示例10: testRewind
function testRewind()
{
$testReversedQueue = new Queue();
$test1 = new Queue();
$test2 = new Queue();
$test3 = new Queue();
$test4 = new Queue();
$test5 = new Queue();
$testReversedQueue->add($test1);
$testReversedQueue->add($test2);
$testReversedQueue->add($test3);
$this->assertReference($test1, $testReversedQueue->next());
$this->assertReference($test2, $testReversedQueue->next());
$testReversedQueue->rewind();
$this->assertReference($test1, $testReversedQueue->next());
}
示例11: getNewItem
public static function getNewItem($params)
{
$format = Utils::getFormat($params['args'], 0, 2);
$projectPage = Utils::getProjectType($params['args']);
$projectSlugIndex = $projectPage == 'system' ? 0 : 2;
$projectSlug = $params['args'][$projectSlugIndex];
$user = User::getAuthenticatedUser();
switch ($params['method']) {
// POST: Get next available item
case 'POST':
$type = Utils::POST('type');
// proof or review
$dispatch = Settings::getProtected('dispatch');
$dispatch->init(array('username' => $user->username, 'projectSlug' => $projectSlug, 'type' => $type));
$response = $dispatch->next();
if ($response['status'] == true) {
$itemId = $response['code'];
// Load the item to make sure it's real
$item = new Item('', $itemId, $projectSlug, $user->username, $type);
// Verification check
if ($item->status == 'available') {
// Put it in the user's queue
$queue = new Queue("user.{$type}:{$user->username}", true);
$queue->add($item);
$queue->save();
}
}
echo json_encode($response);
break;
}
}
示例12: Queue
}
}
}
if ($_POST['editQualys']) {
$simple = new Queue();
$_GET['build'] = $_POST['build'] ? $_POST['build'] : $_POST['build2'];
$_GET['suite'] = "D";
$_GET['command'] = 1;
$_GET['testbed'] = "autoqualys";
$_GET['dbResults'] = "on";
$_GET['userName'] = "nightly";
$_GET['tftpIP'] = 1;
$simple->setAuto($_GET);
$simple->setUid('');
$simple->load();
$simple->add();
}
}
// --- LOAD Queue -----------------------------------------------
$objItemList = new Queue();
$objItemList->addWhere('((status != 5 and DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= creationDate) or ' . '(status = 5 and DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= creationDate))');
if ($_REQUEST['sTestbed']) {
$pUserName = get_magic_quotes_gpc() ? stripslashes($_REQUEST['sTestbed']) : $_REQUEST['sTestbed'];
$objItemList->addWhere('testbed = \'' . addslashes($pUserName) . '\'');
}
if ($_REQUEST['sSuite']) {
$pSuite = $_REQUEST['sSuite'];
$objItemList->addWhere('suite = \'' . $pSuite . '\'');
}
$sqlFilter = '';
$pShow = $_REQUEST['show'] ? $_REQUEST['show'] : 'today';
示例13: getNextAvailableItem
public static function getNextAvailableItem($params)
{
$username = $params['username'];
$projectSlug = $params['projectSlug'];
$type = $params['type'];
$role = $type . "er";
$success = false;
$errorCode = '';
$db = Settings::getProtected('db');
$auth = Settings::getProtected('auth');
// Make sure we're authenticated as the user we say we are
$auth->forceAuthentication();
$loggedInUsername = $auth->getUsername();
if ($username != $loggedInUsername) {
$code = "not-authenticated-as-correct-user";
}
// Load user
$user = new User($username);
// Does this user belong to the project?
if (!$user->isMember($projectSlug, $role)) {
$code = "not-a-member";
}
// Does this user already have an item from this project?
if ($user->hasProjectItem($projectSlug)) {
$code = "has-unfinished-item";
}
// Load the user's queue
$userQueue = new Queue("user.{$type}:{$username}", false, array('include-removed' => true));
$userQueueItems = $userQueue->getItems();
// Load the project's queue
$queue = new Queue("project.{$type}:{$projectSlug}");
$queueItems = $queue->getItems();
// Go through the project queue and get the first item the user hasn't yet done
foreach ($queueItems as $item) {
if (!in_array($item, $userQueueItems)) {
$nextItem = $item;
break;
}
}
if (isset($nextItem) && $nextItem->item_id != -1) {
// Concatenate proofed transcripts
if ($type == 'review') {
// Get proofed transcripts for the new item
$transcripts = $db->loadItemTranscripts($nextItem->project_id, $nextItem->item_id, 'proof');
// Only diff them if there's more than one
if (count($transcripts) > 1) {
$transcriptText = Transcript::diff($transcripts);
} else {
$transcriptText = $transcripts[0]['transcript'];
}
// Only get the fields for the first transcript
$transcriptFields = $transcripts[0]['fields'];
// Create transcript and add to the database
$transcript = new Transcript();
$transcript->setText($transcriptText);
$transcript->setFields($transcriptFields);
$transcript->save(array('item' => $nextItem, 'status' => 'draft', 'type' => 'review'));
}
// Reload the user's queue, this time ignoring items they've already done
// Add it to the user's queue
$userQueue = new Queue("user.{$type}:{$username}", false);
$userQueue->add($nextItem);
$userQueue->save();
// Remove it from the project queue
$queue->remove($nextItem);
$queue->save();
$success = true;
$code = $nextItem->item_id;
} else {
$code = "no-item-available";
}
return array('status' => $success, 'code' => $code);
}