當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HighloadBlockTable::getMultipleValueTableName方法代碼示例

本文整理匯總了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;
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:72,代碼來源:datamanager.php


注:本文中的Bitrix\Highloadblock\HighloadBlockTable::getMultipleValueTableName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。