本文整理汇总了PHP中BxDolModuleDb::lastId方法的典型用法代码示例。如果您正苦于以下问题:PHP BxDolModuleDb::lastId方法的具体用法?PHP BxDolModuleDb::lastId怎么用?PHP BxDolModuleDb::lastId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxDolModuleDb
的用法示例。
在下文中一共展示了BxDolModuleDb::lastId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: BxDolModuleDb
function _addLanguage($aLanguage, $aLangInfo)
{
$oDb = new BxDolModuleDb();
if (getLangIdByName($aLangInfo['Name'])) {
// language already exists
return false;
}
$sLangName = $oDb->escape($aLangInfo['Name']);
$sLangFlag = $oDb->escape($aLangInfo['Flag']);
$sLangTitle = $oDb->escape($aLangInfo['Title']);
if (!$oDb->res("INSERT INTO `sys_localization_languages` VALUES (NULL, '{$sLangName}', '{$sLangFlag}', '{$sLangTitle}')")) {
return false;
}
$iLangKey = $oDb->lastId();
foreach ($aLanguage as $sKey => $sValue) {
$sDbKey = $oDb->escape($sKey);
$sDbValue = $oDb->escape($sValue);
$iExistedKey = $oDb->getOne("SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = '{$sDbKey}'");
if (!$iExistedKey) {
// key is missing, insert new key
if (!$oDb->res("INSERT INTO `sys_localization_keys` VALUES (NULL, " . BX_DOL_LANGUAGE_CATEGORY_SYSTEM . ", '{$sDbKey}')")) {
continue;
}
$iExistedKey = $oDb->lastId();
}
$oDb->res("INSERT INTO `sys_localization_strings` VALUES({$iExistedKey}, {$iLangKey}, '{$sDbValue}')");
}
return true;
}
示例2: BxDolModuleDb
function _addLanguage($aLanguage, $aLangInfo)
{
$oDb = new BxDolModuleDb();
if (getLangIdByName($aLangInfo['Name'])) {
// language already exists
return false;
}
$sLangName = $aLangInfo['Name'];
$sLangFlag = $aLangInfo['Flag'];
$sLangTitle = $aLangInfo['Title'];
$sLangDir = isset($aLangInfo['Direction']) && $aLangInfo['Direction'] ? $aLangInfo['Direction'] : 'LTR';
$sLangCountryCode = isset($aLangInfo['LanguageCountry']) && $aLangInfo['LanguageCountry'] ? $aLangInfo['LanguageCountry'] : $aLangInfo['Name'] . '_' . strtoupper($aLangInfo['Flag']);
if (!$oDb->res("INSERT INTO `sys_localization_languages` VALUES (?, ?, ?, ?, ?, ?)", [NULL, $sLangName, $sLangFlag, $sLangTitle, $sLangDir, $sLangCountryCode])) {
return false;
}
$iLangKey = $oDb->lastId();
foreach ($aLanguage as $sKey => $sValue) {
$sDbKey = $sKey;
$sDbValue = $sValue;
$iExistedKey = $oDb->getOne("SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = ?", [$sDbKey]);
if (!$iExistedKey) {
// key is missing, insert new key
if (!$oDb->res("INSERT INTO `sys_localization_keys` VALUES (NULL, ?, ?)", [BX_DOL_LANGUAGE_CATEGORY_SYSTEM, $sDbKey])) {
continue;
}
$iExistedKey = $oDb->lastId();
}
$oDb->res("INSERT INTO `sys_localization_strings` VALUES(?, ?, ?)", [$iExistedKey, $iLangKey, $sDbValue]);
}
return true;
}