我无法使用模态甜蜜警报插入数据,这是我的脚本:
function gettour(){ swal.setDefaults({ input: 'text', confirmButtonText: 'Next', showCancelButton: true, animation: false, progressSteps: ['1', '2'] }) var steps = [ { input: 'number', title: 'Question 1', text: 'Berapa quantity yang di pesan' }, { input: 'text', title: 'Question 2', text: 'Tanggal Keberangkatan' }, ] swal.queue(steps).then(function (result) { swal.resetDefaults() swal({ }) }, function () { swal.resetDefaults() var qty = result[0]; var tglgo = result[1]; var dataString = 'qty='+qty+'tglgo='+tglgo; $.ajax({ type:'POST', data:dataString, url:'travel.yes/garden/request', success:function(data) { alert(data); } }); }) };
这是我的控制器
public function request() { $qty = $this->input->post('qty'); $tglgo = $this->input->post('tglgo'); $results = $this->model_crud_admin->request_tour($qty,$tglgo); if($results){ redirect('garden/member_area?auth=tour','refresh'); } }
谢谢:)
答案 0 :(得分:0)
您可以使用带有编码器的存储过程来执行此操作。 调用SP并将sp name和array(model)作为参数传递。
答案 1 :(得分:0)
public function CallData($procName, $parameters = null, $isExecute =false, $intColumns= null,$ProvideDb=null){
$syntax = "";
for ($i = 0; $i < count($parameters); $i++) {
$syntax .= (!empty($syntax) ? ',' : '') . '?';
}
$syntax = 'CALL ' . $procName . '(' . $syntax . ');';
if($ProvideDb!=''){
$pdo=DB::connection($ProvideDb)->getPdo();
}
else {
$pdo = DB::connection()->getPdo();
}
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
$stmt = $pdo->prepare($syntax,[\PDO::ATTR_CURSOR=>\PDO::CURSOR_SCROLL]);
for ($i = 0; $i < count($parameters); $i++) {
$stmt->bindValue((1 + $i), $parameters[$i]);
//$stmt->bindParam((1 + $i), $parameters[$i], \PDO::PARAM_INT);
}
$exec = $stmt->execute();
if (!$exec) return $pdo->errorInfo();
if ($isExecute) return $exec;
$results = [];
do {
try {
$results[] = $stmt->fetchAll(\PDO::FETCH_OBJ);
} catch (\Exception $ex) {
}
} while ($stmt->nextRowset());
// This code is added to update string values to int values
if(!empty($intColumns) ) {
for ($i = 0; $i < count($results); $i++) {
$results[$i]= Common::setSelectedPropertyValueToIntOfList($results[$i], $intColumns);
}
}
return $results;
}