第一次用到事务,顺便就写在这里了 /*<br>
* 添加酒店和房型<br>
* */<br>
public function insertAll($arr_hotel=array(),$arr_room=array()){<br>
<br>
$model = new Model();<br>
$model->startTrans();<br>
$flag=false;<br>
<br>
$hid = $model->table(C('DB_PREFIX').'hotel')->add($arr_hotel);<br>
if( $hid && count($arr_room) ==0 ){//如果没有传入房型的信息则,直接提交数据<br>
$model->commit();<br>
$flag=true;<br>
}else if( $hid && count($arr_room) >= 0){//存在对应房型信息,则添加对应的酒店编号,并处理提交<br>
for($i=0 ; $i<count></count>
$arr_room[$i]['hid'] = $hid;<br>
}<br>
$rid = $model->table(C('DB_PREFIX').'room')->addAll($arr_room);<br>
if( $rid ){<br>
$model->commit();<br>
$flag=true;<br>
}<br>
}<br>
<br>
if(!$flag){ <br>
$model->rollback();<br>
}<br>
return $flag;<br>
}
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)