本文整理汇总了PHP中Base_Common::array_insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Base_Common::array_insert方法的具体用法?PHP Base_Common::array_insert怎么用?PHP Base_Common::array_insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base_Common
的用法示例。
在下文中一共展示了Base_Common::array_insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: raceStageGroupSportsTypeAddAction
public function raceStageGroupSportsTypeAddAction()
{
//检查权限
$PermissionCheck = $this->manager->checkMenuPermission("RaceStageModify");
if ($PermissionCheck['return']) {
$RaceStageId = intval($this->request->RaceStageId);
$RaceGroupId = intval($this->request->RaceGroupId);
$SportsTypeId = intval($this->request->SportsTypeId);
$After = isset($this->request->After) ? intval($this->request->After) : 0;
echo "After:" . $After;
//获取当前分站信息
$oRaceStage = $this->oRace->getRaceStage($RaceStageId, '*');
//解包压缩数组
$oRaceStage['comment'] = json_decode($oRaceStage['comment'], true);
//如果当前分站未配置了当前分组
if (!isset($oRaceStage['comment']['SelectedRaceGroup'][$RaceGroupId])) {
//跳转到分站列表页面
$this->response->redirect($this->sign);
}
//获取赛事分组信息
$oRaceGroup = $this->oRace->getRaceGroup($RaceGroupId, '*');
//如果赛事分组尚未配置
if (!$oRaceGroup['RaceGroupId']) {
//跳转到分站列表页面
$this->response->redirect($this->sign);
}
$this->oSports = new Xrace_Sports();
$oSportsType = $this->oSports->getSportsType($SportsTypeId, '*');
if (!isset($oSportsType['SportsTypeId'])) {
$url = Base_Common::getUrl('', 'xrace/race.stage', 'race.stage.group.detail', array('RaceStageId' => $RaceStageId, 'RaceGroupId' => $RaceGroupId));
$this->response->redirect($url);
}
//获取分站分组配置详情
$RaceStageGroupInfo = $this->oRace->getRaceStageGroup($RaceStageId, $RaceGroupId);
//默认开始时间
$StartTime = date("Y-m-d H:i:s", time() + 86400);
//默认结束时间
$EndTime = date("Y-m-d H:i:s", time() + 86400 * 2);
//如果尚未配置分站分组详情,则用默认空数组替代
if (!is_array($RaceStageGroupInfo)) {
$RaceStageGroupInfo = array('PriceList' => 0, 'SingleUser' => 1, 'TeamUser' => 1, 'StartTime' => $StartTime, 'EndTime' => $EndTime, 'comment' => "");
$NewDetail = 1;
}
$RaceStageGroupInfo['comment'] = json_decode($RaceStageGroupInfo['comment'], true);
$RaceStageGroupInfo['comment']['DetailList'] = isset($RaceStageGroupInfo['comment']['DetailList']) ? $RaceStageGroupInfo['comment']['DetailList'] : array();
ksort($RaceStageGroupInfo['comment']['DetailList']);
//如果添加在某个元素之后 且 元素下标不越界
if ($After >= 0 && $After < count(count($RaceStageGroupInfo['comment']['DetailList']))) {
//添加元素
$RaceStageGroupInfo['comment']['DetailList'] = Base_Common::array_insert($RaceStageGroupInfo['comment']['DetailList'], array('SportsTypeId' => $SportsTypeId), $After + 1);
} else {
//默认为在表尾部添加元素
$RaceStageGroupInfo['comment']['DetailList'][count($RaceStageGroupInfo['comment']['DetailList'])] = array('SportsTypeId' => $SportsTypeId);
}
//生成修改后的元素列表
$RaceStageGroupInfo['RaceStageId'] = $RaceStageId;
$RaceStageGroupInfo['RaceGroupId'] = $RaceGroupId;
$RaceStageGroupInfo['comment'] = json_encode($RaceStageGroupInfo['comment']);
//如果认为需要新建数据
if (isset($NewDetail)) {
//插入新的数据
$res = $this->oRace->insertRaceStageGroup($RaceStageGroupInfo);
} else {
//更新数据
$res = $this->oRace->updateRaceStageGroup($RaceStageId, $RaceGroupId, $RaceStageGroupInfo);
}
$url = Base_Common::getUrl('', 'xrace/race.stage', 'race.stage.group.detail', array('RaceStageId' => $RaceStageId, 'RaceGroupId' => $RaceGroupId));
$this->response->redirect($url);
} else {
$home = $this->sign;
include $this->tpl('403');
}
}
示例2: raceSportsTypeInsertAction
public function raceSportsTypeInsertAction()
{
//检查权限
$PermissionCheck = $this->manager->checkMenuPermission("RaceStageModify");
if ($PermissionCheck['return']) {
//分站ID
$RaceStageId = intval($this->request->RaceStageId);
//分组ID
$RaceGroupId = intval($this->request->RaceGroupId);
//比赛ID
$RaceId = intval($this->request->RaceId);
//运动类型ID
$SportsTypeId = intval($this->request->SportsTypeId);
//需要添加的运动类型置于哪个位置之后,默认为开头
$After = isset($this->request->After) ? intval($this->request->After) : -1;
//获取当前分站信息
$RaceStageInfo = $this->oRace->getRaceStage($RaceStageId, '*');
//解包压缩数组
$RaceStageInfo['comment'] = json_decode($RaceStageInfo['comment'], true);
//如果当前分站未配置了当前分组
if (!isset($RaceStageInfo['comment']['SelectedRaceGroup'][$RaceGroupId])) {
$response = array('errno' => 1);
} else {
//获取赛事分组信息
$RaceGroupInfo = $this->oRace->getRaceGroup($RaceGroupId, '*');
//如果赛事分组尚未配置
if (!$RaceGroupInfo['RaceGroupId']) {
$response = array('errno' => 2);
} else {
$this->oSports = new Xrace_Sports();
//获取运动类型信息
$SportsTypeInfo = $this->oSports->getSportsType($SportsTypeId, '*');
//如果未获取到有效的运动类型
if (!isset($SportsTypeInfo['SportsTypeId'])) {
$response = array('errno' => 3);
} else {
//获取比赛信息
$RaceInfo = $this->oRace->getRaceInfo($RaceId);
//如果有获取到比赛信息 并且 赛事分站ID和赛事分组ID相符
if (isset($RaceInfo['RaceId']) && $RaceStageId == $RaceInfo['RaceStageId'] && $RaceGroupId == $RaceInfo['RaceGroupId']) {
//数据解包
$RaceInfo['comment'] = isset($RaceInfo['comment']) ? json_decode($RaceInfo['comment'], true) : array();
//初始运动类型信息列表
$RaceInfo['comment']['DetailList'] = isset($RaceInfo['comment']['DetailList']) ? $RaceInfo['comment']['DetailList'] : array();
//运动类型列表排序
ksort($RaceInfo['comment']['DetailList']);
//如果添加在某个元素之后 且 元素下标不越界
if ($After >= 0 && $After <= count($RaceInfo['comment']['DetailList'])) {
//添加元素
$RaceInfo['comment']['DetailList'] = Base_Common::array_insert($RaceInfo['comment']['DetailList'], array('SportsTypeId' => $SportsTypeId), $After + 1);
} elseif ($After == -1) {
//添加元素
$RaceInfo['comment']['DetailList'] = Base_Common::array_insert($RaceInfo['comment']['DetailList'], array('SportsTypeId' => $SportsTypeId), $After + 1);
} else {
//默认为在表尾部添加元素
$RaceInfo['comment']['DetailList'][count($RaceInfo['comment']['DetailList'])] = array('SportsTypeId' => $SportsTypeId);
}
//数据打包
$RaceInfo['comment'] = json_encode($RaceInfo['comment']);
//更新比赛
$res = $this->oRace->updateRace($RaceId, $RaceInfo);
$response = $res ? array('errno' => 0) : array('errno' => 9);
}
}
}
}
echo json_encode($response);
} else {
$home = $this->sign;
include $this->tpl('403');
}
}
示例3: addTimingPoint
public function addTimingPoint($RaceStageId, $RaceGroupId, $RaceId, $SportsTypeId, $After, $bind)
{
//获取当前分站信息
$RaceStageInfo = $this->getRaceStage($RaceStageId, '*');
//解包压缩数组
$RaceStageInfo['comment'] = json_decode($RaceStageInfo['comment'], true);
//如果当前分站未配置了当前分组
if (!isset($RaceStageInfo['comment']['SelectedRaceGroup'][$RaceGroupId])) {
return false;
} else {
//获取赛事分组信息
$RaceGroupInfo = $this->getRaceGroup($RaceGroupId, '*');
//如果赛事分组尚未配置
if (!$RaceGroupInfo['RaceGroupId']) {
return false;
} else {
//获取比赛信息
$RaceInfo = $this->getRaceInfo($RaceId);
//如果有获取到比赛信息 并且 赛事分站ID和赛事分组ID相符
if (isset($RaceInfo['RaceId']) && $RaceStageId == $RaceInfo['RaceStageId'] && $RaceGroupId == $RaceInfo['RaceGroupId']) {
//数据解包
$RaceInfo['comment'] = isset($RaceInfo['comment']) ? json_decode($RaceInfo['comment'], true) : array();
//获取运动类型的数据
$SportsTypeInfo = $RaceInfo['comment']['DetailList'][$SportsTypeId];
//默认不新建数据
$NewDetail = 0;
//如果有存储对应计时点信息
if (isset($SportsTypeInfo['TimingId']) && $SportsTypeInfo['TimingId'] > 0) {
$SportsTypeInfo['TimingDetailList'] = $this->getTimingDetail($SportsTypeInfo['TimingId']);
if (!is_array($SportsTypeInfo['TimingDetailList'])) {
$NewDetail = 1;
}
} else {
$NewDetail = 1;
}
//初始化运动类型下的计时点列表
$SportsTypeInfo['TimingDetailList']['comment'] = isset($SportsTypeInfo['TimingDetailList']['comment']) ? json_decode($SportsTypeInfo['TimingDetailList']['comment'], true) : array();
$RaceInfo['comment']['DetailList'] = isset($RaceInfo['comment']['DetailList']) ? $RaceInfo['comment']['DetailList'] : array();
ksort($RaceInfo['comment']['DetailList']);
//如果添加在某个元素之后 且 元素下标不越界
if ($After >= 0 && $After <= count($SportsTypeInfo['TimingDetailList']['comment'])) {
//添加元素
$SportsTypeInfo['TimingDetailList']['comment'] = Base_Common::array_insert($SportsTypeInfo['TimingDetailList']['comment'], $bind, $After + 1);
} elseif ($After == -1) {
//添加元素
$SportsTypeInfo['TimingDetailList']['comment'] = Base_Common::array_insert($SportsTypeInfo['TimingDetailList']['comment'], $bind, $After + 1);
} else {
//默认为在表尾部添加元素
$SportsTypeInfo['TimingDetailList']['comment'][count($SportsTypeInfo['TimingDetailList']['comment'])] = $bind;
}
$this->db->begin();
//如果认为需要新建数据
if ($NewDetail == 1) {
$insertBind['comment'] = json_encode($SportsTypeInfo['TimingDetailList']['comment']);
$TimingId = $this->insertTimingDetail($insertBind);
if ($TimingId) {
$RaceInfo['comment']['DetailList'][$SportsTypeId]['TimingId'] = $TimingId;
$RaceInfo['comment'] = json_encode($RaceInfo['comment']);
$RaceStageGroupModify = $this->updateRace($RaceId, $RaceInfo);
if ($RaceStageGroupModify) {
$this->db->commit();
return true;
} else {
$this->db->rollback();
return false;
}
} else {
$this->db->rollback();
return false;
}
} else {
$updateBind = array('comment' => json_encode($SportsTypeInfo['TimingDetailList']['comment']));
$TimingDetailUpdate = $this->updateTimingDetail($SportsTypeInfo['TimingId'], $updateBind);
if ($TimingDetailUpdate) {
$this->db->commit();
return true;
} else {
$this->db->rollback();
return false;
}
}
} else {
return false;
}
}
}
}