本文整理汇总了PHP中Sequence类的典型用法代码示例。如果您正苦于以下问题:PHP Sequence类的具体用法?PHP Sequence怎么用?PHP Sequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate()
{
$model = new ProductAddition();
$model->dpid = $this->companyId;
$pslid = Yii::app()->request->getParam('psid');
$model->mproduct_id = $pslid;
if (Yii::app()->request->isPostRequest) {
$model->attributes = Yii::app()->request->getPost('ProductAddition');
//var_dump($model->attributes);exit;
$se = new Sequence("product_addition");
$model->lid = $se->nextval();
$model->create_at = date('Y-m-d H:i:s', time());
$model->update_at = date('Y-m-d H:i:s', time());
$model->delete_flag = '0';
//var_dump($model);exit;
if ($model->save()) {
Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
$this->redirect(array('productAddition/detail', 'companyId' => $this->companyId, 'lid' => $model->mproduct_id));
}
}
$categories = $this->getCategories();
$categoryId = 0;
$products = $this->getProducts($categoryId);
$productslist = CHtml::listData($products, 'lid', 'product_name');
$this->render('detailcreate', array('model' => $model, 'categories' => $categories, 'categoryId' => $categoryId, 'products' => $productslist));
}
示例2: saveMsg
/**
* 被下单、加菜、在线支付、信息反馈等调用
* 对应的cmd分别是XD、JC、ZXZF、XXFK
* data的格式按照接口文档封装
*/
protected function saveMsg($cmd, $data)
{
$db = Yii::app()->db;
$se = new Sequence("data_sync");
$this->lid = $se->nextval();
$sql = 'insert into nb_data_sync(lid,dpid,cmd_code,cmd_data,create_at,is_interface,sync_result) values(:lid,:dpid,:cmd_code,:cmd_data,sysdate(),:is_interface,:sync_result)';
$command = $db->createCommand($sql);
$command->bindValue(":lid", $this->lid);
$command->bindValue(":dpid", $this->dpid);
$command->bindValue(":cmd_code", $cmd);
$command->bindValue(":cmd_data", $data);
$command->bindValue(":is_interface", '1');
$command->bindValue(":sync_result", '0');
$command->execute();
/*$ds=new DataSync;
$se=new Sequence("data_sync");
$this->lid = $se->nextval();
$ds->dpid = $this->dpid;
$ds->lid = $this->lid;
$ds->cmd_code = $cmd;
$ds->cmd_data =$data;
$ds->create_at = date('y-m-d h:i:s',time());
$ds->is_interface = '1';
$ds->sync_result = '0';
$ds->save();*/
}
示例3: actionCreate
public function actionCreate()
{
$model = new Product();
$model->dpid = $this->companyId;
//$model->create_time = time();
if (Yii::app()->request->isPostRequest) {
$model->attributes = Yii::app()->request->getPost('Product');
$se = new Sequence("product");
$model->lid = $se->nextval();
$model->create_at = date('Y-m-d H:i:s', time());
$model->update_at = date('Y-m-d H:i:s', time());
$model->delete_flag = '0';
$py = new Pinyin();
$model->simple_code = $py->py($model->product_name);
//var_dump($model);exit;
if ($model->save()) {
Yii::app()->user->setFlash('success', yii::t('app', '添加成功!'));
$this->redirect(array('product/index', 'companyId' => $this->companyId));
}
}
$categories = $this->getCategoryList();
//$departments = $this->getDepartments();
//echo 'ss';exit;
$this->render('create', array('model' => $model, 'categories' => $categories));
}
示例4: actionGetSitePersons
public function actionGetSitePersons()
{
$companyid = Yii::app()->request->getParam('companyid', 0);
$padid = Yii::app()->request->getParam('padid', 0);
$stlid = Yii::app()->request->getParam('stlid', 0);
$splid = Yii::app()->request->getParam('splid', 0);
$ret = array();
$nowqueueno = "000";
$queueno = "A001";
$waitingno = 0;
if (empty($companyid) || empty($padid)) {
Yii::app()->end(json_encode(array('status' => false, 'msg' => '店铺或设备不存在!')));
}
$pad = Pad::model()->with("printer")->find(' t.dpid=:companyId and t.lid=:padid', array(':companyId' => $companyid, ':padid' => $padid));
//var_dump($pad);exit;
if (!empty($pad)) {
//生成新的排队号
$siteType = SiteType::model()->find(" dpid=:dpid and lid=:lid", array(":dpid" => $companyid, ":lid" => $stlid));
//var_dump($siteType);exit;
$criteria = new CDbCriteria();
$criteria->condition = " dpid=" . $companyid . " and stlid=" . $stlid . " and splid=" . $splid . " and create_at >='" . date('Y-m-d', time()) . " 00:00:00' and create_at <='" . date('Y-m-d', time()) . " 23:59:59'";
$criteria->order = ' lid ';
$queuePerson = QueuePersons::model()->findAll($criteria);
if (empty($siteType)) {
Yii::app()->end(json_encode(array('status' => false, 'msg' => '座位类型不存在!')));
}
//var_dump($queuePerson);exit;
if (!empty($queuePerson)) {
$countsp = count($queuePerson);
$queueno = $siteType->simplecode . substr("000" . (string) ($countsp + 1), -3);
for ($sti = $countsp - 1; $sti >= 0; $sti--) {
if ($queuePerson[$sti]->status == "0") {
$waitingno++;
} else {
break;
}
}
} else {
$queueno = $siteType->simplecode . "001";
$waitingno = 0;
}
$se = new Sequence("queue_persons");
$queuelid = $se->nextval();
$data = array('lid' => $queuelid, 'dpid' => $companyid, 'create_at' => date('Y-m-d H:i:s', time()), 'update_at' => date('Y-m-d H:i:s', time()), 'stlid' => $stlid, 'splid' => $splid, 'queue_no' => $queueno, 'status' => '0', 'slid' => "0000000000", 'delete_flag' => '0');
Yii::app()->db->createCommand()->insert('nb_queue_persons', $data);
$waitingno++;
//返回现有的等待人数
$precode = "";
$printserver = "0";
//
$memo = "排队号:" . $queueno . ",(还有" . $waitingno . "组在等待)";
$ret = Helper::printQueue($pad, $precode, $printserver, $memo);
if ($ret['status']) {
$ret['waitingnum'] = $waitingno;
}
} else {
$ret = array('status' => false, 'msg' => '没有找到PAD');
}
Yii::app()->end(json_encode($ret));
}
示例5: actionCreate
public function actionCreate()
{
$typeId = Yii::app()->request->getParam('typeId', 0);
$model = new Site();
$model->dpid = $this->companyId;
$model->type_id = $typeId;
if (Yii::app()->request->isPostRequest) {
$model->attributes = Yii::app()->request->getPost('Site');
$se = new Sequence("site");
$model->lid = $se->nextval();
$model->create_at = date('Y-m-d H:i:s', time());
$model->update_at = date('Y-m-d H:i:s', time());
$model->delete_flag = '0';
//var_dump($model);exit;
if ($model->save()) {
Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
$this->redirect(array('site/index', 'typeId' => $typeId, 'companyId' => $this->companyId));
}
}
$types = $this->getTypes();
$floors = $this->getFloors();
$sitepersons = $this->getSitePersons();
//var_dump($floors);
//var_dump($types);exit;
$this->render('create', array('model' => $model, 'types' => $types, 'floors' => $floors, 'sitepersons' => $sitepersons));
}
示例6: testShouldGroupThreeGroupsElement
public function testShouldGroupThreeGroupsElement()
{
$sequence = new Sequence([1, 2, 3, 5, 7]);
$result = $sequence->group();
$expected = [[1, 3], [5], [7]];
$this->assertEquals($expected, $result);
}
示例7: testCannotShrinkSomethingThatIsNotContainedInDomain
/**
* @expectedException DomainException
*/
public function testCannotShrinkSomethingThatIsNotContainedInDomain()
{
$aString = 'a string';
$this->assertFalse($this->singleElementGenerator->contains($aString));
$generator = new Sequence($this->singleElementGenerator);
$generator->shrink([$aString]);
}
示例8: saveCmd
public function saveCmd($cmd)
{
//$ds=new DataSync();
$db = Yii::app()->db;
$se = new Sequence("data_sync");
$this->lid = $se->nextval();
$sql = 'insert into nb_data_sync(lid,dpid,cmd_code,cmd_data,create_at,is_interface,sync_result) values(:lid,:dpid,:cmd_code,:cmd_data,sysdate(),:is_interface,:sync_result)';
$command = $db->createCommand($sql);
$command->bindValue(":lid", $this->lid);
$command->bindValue(":dpid", $this->dpid);
$command->bindValue(":cmd_code", $cmd);
$command->bindValue(":cmd_data", '');
$command->bindValue(":is_interface", '1');
$command->bindValue(":sync_result", '0');
$command->execute();
/*
$ds->dpid = $this->dpid;
$ds->lid = $this->lid;
$ds->cmd_code = $cmd;
$ds->cmd_data = '';
$ds->create_at = date('y-m-d h:i:s',time());
$ds->is_interface = '1';
$ds->sync_result = '0';
//var_dump($ds);
if(!$ds->save())
{
var_dump($ds->getErrors());
echo 'insert error!!!!';
}*/
}
示例9: beforeSave
public function beforeSave($data)
{
$defaults = array();
$files = array();
// set new sequential ID
$sequence = new Sequence();
$seq = $sequence->getNewId('property');
$data['sequence'] = $seq;
$data['propertyId'] = Config::get('ia.property_id_prefix') . $seq;
if ($data['submit'] == 'Publish') {
$data['publishStatus'] = 'published';
} else {
$data['publishStatus'] = 'draft';
}
$data['publishDate'] = $data['lastUpdate'];
if (isset($data['file_id']) && count($data['file_id'])) {
$data['defaultpic'] = isset($data['defaultpic']) ? $data['defaultpic'] : $data['file_id'][0];
for ($i = 0; $i < count($data['thumbnail_url']); $i++) {
if ($data['defaultpic'] == $data['file_id'][$i]) {
$defaults['thumbnail_url'] = $data['thumbnail_url'][$i];
$defaults['large_url'] = $data['large_url'][$i];
$defaults['medium_url'] = $data['medium_url'][$i];
}
$files[$data['file_id'][$i]]['thumbnail_url'] = $data['thumbnail_url'][$i];
$files[$data['file_id'][$i]]['large_url'] = $data['large_url'][$i];
$files[$data['file_id'][$i]]['medium_url'] = $data['medium_url'][$i];
$files[$data['file_id'][$i]]['delete_type'] = $data['delete_type'][$i];
$files[$data['file_id'][$i]]['delete_url'] = $data['delete_url'][$i];
$files[$data['file_id'][$i]]['filename'] = $data['filename'][$i];
$files[$data['file_id'][$i]]['filesize'] = $data['filesize'][$i];
$files[$data['file_id'][$i]]['temp_dir'] = $data['temp_dir'][$i];
$files[$data['file_id'][$i]]['filetype'] = $data['filetype'][$i];
$files[$data['file_id'][$i]]['fileurl'] = $data['fileurl'][$i];
$files[$data['file_id'][$i]]['file_id'] = $data['file_id'][$i];
$files[$data['file_id'][$i]]['caption'] = $data['caption'][$i];
}
} else {
$data['thumbnail_url'] = array();
$data['large_url'] = array();
$data['medium_url'] = array();
$data['delete_type'] = array();
$data['delete_url'] = array();
$data['filename'] = array();
$data['filesize'] = array();
$data['temp_dir'] = array();
$data['filetype'] = array();
$data['fileurl'] = array();
$data['file_id'] = array();
$data['caption'] = array();
$data['defaultpic'] = '';
}
$data['defaultpictures'] = $defaults;
$data['files'] = $files;
return $data;
}
示例10: testInterviewQuestionA
public function testInterviewQuestionA()
{
/*
The sum of all natural numbers below 10 that are multiples of 3 or 5 are 23 (3 + 5 + 6 + 9)
Write a php script that will find the sum of all the multiples of 3 or 5 below 1000. The script
should run from command line and put the result on screen. We will judge this task based on
simplicity, efficiency and cleverness of the code.
*/
$limit = 1000;
$values = range(0, $limit);
$a = 3;
$b = 5;
$fnFilterMaker = function ($a, $b) {
return function ($v) use($a, $b) {
return $v % $a == 0 || $v % $b == 0;
};
};
// test: sum of multiples of 3 or 5 below 10 is 23 (3 + 5 + 6 + 9)
$this->assertTrue(Sequence::make(range(0, 9))->filter($fnFilterMaker(3, 5))->reduce(0, FnGen::fnSum()) == 23);
$filteredValues = Sequence::make($values)->filter($fnFilterMaker($a, $b))->to_a();
$this->assertArrayHasKey($a, $filteredValues);
$this->assertArrayHasKey($b, $filteredValues);
$this->assertArrayNotHasKey($a * $b + 1, $filteredValues);
$valuesOnly = array_values($filteredValues);
$subsetA = range(0, $limit, $a);
$subsetB = range(0, $limit, $b);
$this->assertTrue($subsetA == array_values(array_intersect($valuesOnly, $subsetA)));
$this->assertTrue($subsetB == array_values(array_intersect($valuesOnly, $subsetB)));
$this->assertTrue(!count(array_diff($valuesOnly, $subsetA, $subsetB)));
}
示例11: run
function run($max_time) {
global $cfg;
$i18n = new Internationalization($cfg->get('system_language', 'en_US'));
$sequences = $i18n->getTemplate('sequence.yaml')->getData();
foreach ($sequences as $s) {
Sequence::create($s)->save();
}
db_query('UPDATE '.SEQUENCE_TABLE.' SET `next`= '
.'(SELECT MAX(ticket_id)+1 FROM '.TICKET_TABLE.') '
.'WHERE `id`=1');
require_once(INCLUDE_DIR . 'class.list.php');
$lists = $i18n->getTemplate('list.yaml')->getData();
foreach ($lists as $l) {
DynamicList::create($l);
}
$statuses = $i18n->getTemplate('ticket_status.yaml')->getData();
foreach ($statuses as $s) {
TicketStatus::__create($s);
}
// Initialize MYSQL search backend
MysqlSearchBackend::__init();
}
示例12: generateDatasetName
public static function generateDatasetName() {
$sequenceName = 'dataset.name';
$datasetSuffixId = Sequence::getNextSequenceValue($sequenceName);
$datasetSuffix = str_pad(base_convert($datasetSuffixId, 10, 36), self::$LENGTH_NAME__DATASET, '0', STR_PAD_LEFT);
return self::$PREFIX_NAME__DATASET . $datasetSuffix;
}
示例13: actionCreate
public function actionCreate()
{
$model = new Printer();
$model->dpid = $this->companyId;
if (Yii::app()->request->isPostRequest) {
$model->attributes = Yii::app()->request->getPost('Printer');
$se = new Sequence("printer");
$model->lid = $se->nextval();
$model->create_at = date('Y-m-d H:i:s', time());
$model->update_at = date('Y-m-d H:i:s', time());
$model->delete_flag = '0';
if ($model->save()) {
Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
$this->redirect(array('printer/index', 'companyId' => $this->companyId));
}
}
$this->render('create', array('model' => $model));
}
示例14: getRequestId
protected function getRequestId() {
$requestId = &drupal_static(__CLASS__ . '::requestId');
if (!isset($requestId)) {
$sequenceName = NameSpaceHelper::addNameSpace(get_class($this), 'requestId');
$requestId = Sequence::getNextSequenceValue($sequenceName);
}
return $requestId;
}
示例15: actionCreate
public function actionCreate()
{
$companyId = Helper::getCompanyId(Yii::app()->request->getParam('companyId'));
$model = new CompanyWifi();
$model->dpid = $companyId;
if (Yii::app()->request->isPostRequest) {
$model->attributes = Yii::app()->request->getPost('CompanyWifi');
$se = new Sequence("company_wifi");
$model->lid = $se->nextval();
$model->create_at = date('Y-m-d H:i:s');
$model->update_at = date('Y-m-d H:i:s');
if ($model->save()) {
Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
$this->redirect(array('companyWifi/index', 'companyId' => $companyId));
}
}
$this->render('create', array('model' => $model));
}