本文整理匯總了PHP中Bitrix\Highloadblock\HighloadBlockTable::getMultipleValueTableName方法的典型用法代碼示例。如果您正苦於以下問題:PHP HighloadBlockTable::getMultipleValueTableName方法的具體用法?PHP HighloadBlockTable::getMultipleValueTableName怎麽用?PHP HighloadBlockTable::getMultipleValueTableName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bitrix\Highloadblock\HighloadBlockTable
的用法示例。
在下文中一共展示了HighloadBlockTable::getMultipleValueTableName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: delete
/**
* @param mixed $primary
*
* @return Entity\DeleteResult
*/
public static function delete($primary)
{
global $USER_FIELD_MANAGER;
// check primary
static::normalizePrimary($primary);
static::validatePrimary($primary);
// get old data
$oldData = static::getByPrimary($primary)->fetch();
$hlblock = static::getHighloadBlock();
$entity = static::getEntity();
$result = new Entity\DeleteResult();
//event before delete
$event = new Entity\Event($entity, self::EVENT_ON_BEFORE_DELETE, array("id" => $primary));
$event->send();
$event->getErrors($result);
//event before delete (modern with namespace)
$event = new Entity\Event($entity, self::EVENT_ON_BEFORE_DELETE, array("id" => $primary, "primary" => $primary, "oldFields" => $oldData), true);
$event->send();
$event->getErrors($result);
// return if any error
if (!$result->isSuccess(true)) {
return $result;
}
//event on delete
$event = new Entity\Event($entity, self::EVENT_ON_DELETE, array("id" => $primary));
$event->send();
//event on delete (modern with namespace)
$event = new Entity\Event($entity, self::EVENT_ON_DELETE, array("id" => $primary, "primary" => $primary, "oldFields" => $oldData), true);
$event->send();
// remove row
$connection = Main\Application::getConnection();
$helper = $connection->getSqlHelper();
$tableName = $entity->getDBTableName();
$id = array();
foreach ($primary as $k => $v) {
$id[] = $k . " = '" . $helper->forSql($v) . "'";
}
$where = implode(' AND ', $id);
$sql = "DELETE FROM " . $tableName . " WHERE " . $where;
$connection->queryExecute($sql);
$fields = $USER_FIELD_MANAGER->getUserFields('HLBLOCK_' . $hlblock['ID']);
foreach ($oldData as $k => $v) {
$userfield = $fields[$k];
// remove multi values
if ($userfield['MULTIPLE'] == 'Y') {
$utmTableName = HighloadBlockTable::getMultipleValueTableName($hlblock, $userfield);
$connection->query(sprintf('DELETE FROM %s WHERE %s = %d', $helper->quote($utmTableName), $helper->quote('ID'), $primary['ID']));
}
// remove files
if ($userfield["USER_TYPE"]["BASE_TYPE"] == "file") {
if (is_array($oldData[$k])) {
foreach ($oldData[$k] as $value) {
\CFile::delete($value);
}
} else {
\CFile::delete($oldData[$k]);
}
}
}
//event after delete
$event = new Entity\Event($entity, self::EVENT_ON_AFTER_DELETE, array("id" => $primary));
$event->send();
//event after delete (modern with namespace)
$event = new Entity\Event($entity, self::EVENT_ON_AFTER_DELETE, array("id" => $primary, "primary" => $primary, "oldFields" => $oldData), true);
$event->send();
return $result;
}