本文整理汇总了PHP中FDB::insertId方法的典型用法代码示例。如果您正苦于以下问题:PHP FDB::insertId方法的具体用法?PHP FDB::insertId怎么用?PHP FDB::insertId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FDB
的用法示例。
在下文中一共展示了FDB::insertId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
/**
* 添加数据
* @access public
* @param string $table 表名
* @param array $data 数据
* @param bool $return_insert_id 是否返回 INSERT 操作产生的 ID 默认为false不返回
* @param bool $replace 是否为替换操作 默认为false
* @param bool $silent 不显示错误 默认为flase(显示)
* @return mixed
*/
public function insert($table, $data, $return_insert_id = false, $replace = false, $silent = false)
{
$sql = FDB::implodeFieldValue($data);
$cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
$table = FDB::table($table);
$silent = $silent ? 'SILENT' : '';
$return = FDB::query("{$cmd} {$table} SET {$sql}", $silent);
return $return_insert_id ? FDB::insertId() : $return;
}
示例2: replyMsg
/**
* 回复信息
* @param int $mlid 信件组编号
* @param int $fuid 发信会员编号
* @param string $fusername 发信会员名称
* @param string $message 信件内容
* @return int
*/
public function replyMsg($mlid, $fuid, $fusername, $message)
{
if (empty($mlid) || empty($fuid) || empty($fusername) || empty($message)) {
return 0;
}
$mlist = FDB::fetchFirst("SELECT * FROM " . FDB::table('user_msg_list') . " WHERE mlid='{$mlid}'");
if (empty($mlist)) {
return MSG_MLIST_NONE_ERROR;
}
if ($mlist['type'] == 1) {
$users = explode('_', $mlist['min_max']);
if ($users[0] == $fuid) {
$tuid = $users[1];
} elseif ($users[1] == $fuid) {
$tuid = $users[0];
} else {
return MSG_PRIVILEGE_NONE_ERROR;
}
}
$members = array();
$query = FDB::query("SELECT * FROM " . FDB::table('user_msg_member') . " WHERE mlid='{$mlid}'");
while ($member = FDB::fetch($query)) {
$members[$member['uid']] = "('{$member['uid']}')";
}
if (!isset($members[$fuid])) {
return MSG_PRIVILEGE_NONE_ERROR;
}
$last_msg = htmlspecialchars(cutStr(clearExpress(trim($message)), 150));
$type = 0;
FDB::query("INSERT INTO " . FDB::table('user_msg_index') . "(mlid) VALUES('{$mlid}')");
$miid = FDB::insertId();
FDB::query("INSERT INTO " . MessageService::getTablaName($mlid) . "(miid,mlid,uid,message,dateline,status) VALUES('{$miid}', '{$mlid}', '{$fuid}', '{$message}', '" . TIME_UTC . "', 0)");
if ($mlist['type'] == 1) {
$msg_config = array('last_uid' => $fuid, 'last_user_name' => $fusername, 'last_msg' => $last_msg);
$msg_config = addslashes(serialize($msg_config));
$result = FDB::query("INSERT INTO " . FDB::table('user_msg_member') . "(mlid, uid, is_new, num, last_update, last_dateline) VALUES('{$mlid}', '{$tuid}', '1', '1', '0', '" . TIME_UTC . "')", 'SILENT');
if (!$result) {
FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new = 1, num = num + 1, last_dateline='" . TIME_UTC . "' WHERE mlid='{$mlid}' AND uid='{$tuid}'");
}
FDB::query("UPDATE " . FDB::table('user_msg_member') . " SET is_new = 0, num = num + 1, last_update='" . TIME_UTC . "', last_dateline='" . TIME_UTC . "' WHERE mlid='{$mlid}' AND uid='{$fuid}'");
} else {
}
FDB::query("UPDATE " . FDB::table('user_msg_list') . " SET msg_config='{$msg_config}' WHERE mlid='{$mlid}'");
$result = FDB::query("INSERT INTO " . FDB::table('user_notice') . "(uid, type, num, create_time) VALUES('{$tuid}',5,1,'" . TIME_UTC . "')", 'SILENT');
if (!$result) {
FDB::query("UPDATE " . FDB::table('user_notice') . " SET num = num + 1, create_time='" . TIME_UTC . "' WHERE uid='{$tuid}' AND type=5");
}
return $miid;
}