本文整理匯總了PHP中Bitrix\Highloadblock\HighloadBlockTable::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP HighloadBlockTable::add方法的具體用法?PHP HighloadBlockTable::add怎麽用?PHP HighloadBlockTable::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bitrix\Highloadblock\HighloadBlockTable
的用法示例。
在下文中一共展示了HighloadBlockTable::add方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addHlblock
public function addHlblock($fields)
{
$this->checkRequiredKeys(__METHOD__, $fields, array('NAME', 'TABLE_NAME'));
$fields['NAME'] = ucfirst($fields['NAME']);
$result = HL\HighloadBlockTable::add($fields);
if ($result->getId()) {
return $result->getId();
}
$this->throwException(__METHOD__, implode(', ', $result->getErrors()));
}
示例2: Add
/**
* Add
* @param $entityName
* @param $tableName
* @return bool
* @throws \Exception
*/
public static function Add($entityName, $tableName)
{
if (empty($entityName)) {
throw new BimException('entityName is empty');
}
if (empty($tableName)) {
throw new BimException('tableName is empty');
}
$addFields = array('NAME' => trim($entityName), 'TABLE_NAME' => trim($tableName));
$addResult = HL\HighloadBlockTable::add($addFields);
if (!$addResult->isSuccess()) {
throw new \Exception(implode(", ", $addResult->getErrorMessages()));
}
return true;
}
示例3: array
use Bitrix\Highloadblock as HL;
$dbHblock = HL\HighloadBlockTable::getList(
array(
"filter" => array("NAME" => "ColorReference")
)
);
if ($dbHblock->Fetch())
return;
$data = array(
'NAME' => 'ColorReference',
'TABLE_NAME' => 'eshop_color_reference',
);
$result = HL\HighloadBlockTable::add($data);
$ID = $result->getId();
$_SESSION["ESHOP_HBLOCK_ID"] = $ID;
$hldata = HL\HighloadBlockTable::getById($ID)->fetch();
$hlentity = HL\HighloadBlockTable::compileEntity($hldata);
//adding user fields
$arUserFields = array (
array (
'ENTITY_ID' => 'HLBLOCK_'.$ID,
'FIELD_NAME' => 'UF_NAME',
'USER_TYPE_ID' => 'string',
'XML_ID' => 'UF_COLOR_NAME',
'SORT' => '100',
示例4: infrastructureCheck
/**
* @return array
*/
protected function infrastructureCheck()
{
$table = $this->getTableName();
$modelName = $this->getModelName();
//проверяем существует ли таблица миграций
$filter = array('select' => array('ID', 'NAME', 'TABLE_NAME'), 'filter' => array('=TABLE_NAME' => $table));
$hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList($filter)->fetch();
//создаем таблицу, если она не существует
if (empty($hlblock['ID'])) {
$result = \Bitrix\Highloadblock\HighloadBlockTable::add(['NAME' => $modelName, 'TABLE_NAME' => $table]);
$id = $result->getId();
if (!$id) {
throw new \marvin255\bxmigrate\Exception('Can\'t create HL table');
}
} else {
$id = $hlblock['ID'];
}
//проверяем поля таблицы, чтобы были все
$fields = [];
$rsData = CUserTypeEntity::GetList([], ['ENTITY_ID' => "HLBLOCK_{$id}"]);
while ($ob = $rsData->GetNext()) {
$fields[$ob['FIELD_NAME']] = $ob['ID'];
}
//название миграции
if (empty($fields['UF_MIGRATION_NAME'])) {
$obUserField = new CUserTypeEntity();
$idRes = $obUserField->Add(['USER_TYPE_ID' => 'string', 'ENTITY_ID' => "HLBLOCK_{$id}", 'FIELD_NAME' => 'UF_MIGRATION_NAME', 'EDIT_FORM_LABEL' => ['ru' => 'Название миграции']]);
if (!$idRes) {
throw new \marvin255\bxmigrate\Exception('Can\'t create UF_MIGRATION_NAME property');
}
}
//дата миграции
if (empty($fields['UF_MIGRATION_DATE'])) {
$obUserField = new CUserTypeEntity();
$idRes = $obUserField->Add(['USER_TYPE_ID' => 'string', 'ENTITY_ID' => "HLBLOCK_{$id}", 'FIELD_NAME' => 'UF_MIGRATION_DATE', 'EDIT_FORM_LABEL' => ['ru' => 'Дата миграции']]);
if (!$idRes) {
throw new \marvin255\bxmigrate\Exception('Can\'t create UF_MIGRATION_DATE property');
}
}
return ['ID' => $id, 'NAME' => $modelName, 'TABLE_NAME' => $table];
}