本文整理汇总了PHP中Bitrix\Main\Type\DateTime::format方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::format方法的具体用法?PHP DateTime::format怎么用?PHP DateTime::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Type\DateTime
的用法示例。
在下文中一共展示了DateTime::format方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public static function register($ownerID, array $entityFields = null, array $options = null)
{
if (!is_int($ownerID)) {
$ownerID = (int) $ownerID;
}
if ($ownerID <= 0) {
throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
}
if (!is_array($options)) {
$options = array();
}
if (!is_array($entityFields)) {
$dbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'STAGE_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE'));
$entityFields = is_object($dbResult) ? $dbResult->Fetch() : null;
if (!is_array($entityFields)) {
return false;
}
}
$stageID = isset($entityFields['STAGE_ID']) ? $entityFields['STAGE_ID'] : '';
if ($stageID === '') {
return false;
}
$responsibleID = isset($entityFields['ASSIGNED_BY_ID']) ? (int) $entityFields['ASSIGNED_BY_ID'] : 0;
$startDate = self::parseDateString(isset($entityFields['BEGINDATE']) ? $entityFields['BEGINDATE'] : '');
if ($startDate === null) {
$startDate = new Date();
}
$endDate = self::parseDateString(isset($entityFields['CLOSEDATE']) ? $entityFields['CLOSEDATE'] : '');
if ($endDate === null) {
$endDate = new Date('9999-12-31', 'Y-m-d');
}
$time = isset($options['TIME']) ? $options['TIME'] : null;
if ($time === null) {
$time = new DateTime();
}
$month = (int) $time->format('m');
$quarter = $month <= 3 ? 1 : ($month <= 6 ? 2 : ($month <= 9 ? 3 : 4));
$year = (int) $time->format('Y');
$startMonth = (int) $startDate->format('m');
$startQuarter = $startMonth <= 3 ? 1 : ($startMonth <= 6 ? 2 : ($startMonth <= 9 ? 3 : 4));
$startYear = (int) $startDate->format('Y');
$endMonth = (int) $endDate->format('m');
$endQuarter = $endMonth <= 3 ? 1 : ($endMonth <= 6 ? 2 : ($endMonth <= 9 ? 3 : 4));
$endYear = (int) $endDate->format('Y');
$semanticID = \CCrmDeal::GetSemanticID($stageID);
$isNew = isset($options['IS_NEW']) ? (bool) $options['IS_NEW'] : false;
$typeID = PhaseSemantics::isFinal($semanticID) ? HistoryEntryType::FINALIZATION : ($isNew ? HistoryEntryType::CREATION : HistoryEntryType::MODIFICATION);
$date = Date::createFromTimestamp($time->getTimestamp());
$isLost = PhaseSemantics::isLost($semanticID);
$latest = self::getLatest($ownerID);
if ($latest['STAGE_ID'] === $stageID) {
return false;
}
$result = DealStageHistoryTable::add(array('TYPE_ID' => $typeID, 'OWNER_ID' => $ownerID, 'CREATED_TIME' => $time, 'CREATED_DATE' => $date, 'START_DATE' => $startDate, 'END_DATE' => $endDate, 'PERIOD_YEAR' => $year, 'PERIOD_QUARTER' => $quarter, 'PERIOD_MONTH' => $month, 'START_PERIOD_YEAR' => $startYear, 'START_PERIOD_QUARTER' => $startQuarter, 'START_PERIOD_MONTH' => $startMonth, 'END_PERIOD_YEAR' => $endYear, 'END_PERIOD_QUARTER' => $endQuarter, 'END_PERIOD_MONTH' => $endMonth, 'RESPONSIBLE_ID' => $responsibleID, 'STAGE_ID' => $stageID, 'STAGE_SEMANTIC_ID' => $semanticID, 'IS_LOST' => $isLost ? 'Y' : 'N'));
if ($result->isSuccess() && $result->getId() > 0 && is_array($latest) && (int) $latest['TYPE_ID'] === HistoryEntryType::FINALIZATION) {
DealStageHistoryTable::delete($latest['ID']);
}
return true;
}
示例2: externalize
public function externalize()
{
$result = array('srcEntityTypeID' => $this->srcEntityTypeID, 'dstEntityTypeID' => $this->dstEntityTypeID, 'time' => $this->time->format(\DateTime::ISO8601), 'items' => array());
if ($this->srcIndex !== null) {
foreach ($this->srcIndex as $item) {
$result['items'][] = $item->externalize();
}
}
return $result;
}
示例3: onGenerateInitialData
public static function onGenerateInitialData(Date $from, Date $to)
{
$data = array();
// 1. Payments
$result = \CSaleOrder::GetList(array(), array('PAYED' => 'Y', 'CANCELED' => 'N', '>=DATE_PAYED' => $from, '<=DATE_PAYED' => $to), false, false, array('LID', 'DATE_PAYED', 'PRICE', 'CURRENCY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_PAYED']);
$sum = Config::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_payment_add_day'] += 1;
$counters['sale_payment_sum_add'] += $sum;
} else {
$counters = array('sale_payment_add_day' => 1, 'sale_payment_sum_add' => $sum);
}
}
// 2. Orders
$result = \CSaleOrder::GetList(array(), array('CANCELED' => 'N', '>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_INSERT']);
$sum = Config::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_order_add_day'] += 1;
$counters['sale_order_sum_add'] += $sum;
} else {
$counters = array('sale_order_add_day' => 1, 'sale_order_sum_add' => $sum);
}
}
// 3. Cart
$result = \CSaleBasket::GetList(array(), array('>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY', 'QUANTITY'));
while ($row = $result->Fetch()) {
$day = new DateTime($row['DATE_INSERT']);
$sum = Config::convertToBaseCurrency($row['PRICE'] * $row['QUANTITY'], $row['CURRENCY']);
if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
$counters['sale_cart_add_day'] += 1;
$counters['sale_cart_sum_add'] += $sum;
} else {
$counters = array('sale_cart_add_day' => 1, 'sale_cart_sum_add' => $sum);
}
}
// Result
unset($counters);
$result = array();
foreach ($data as $siteId => $dayCounters) {
$result[] = array('ATTRIBUTES' => array('conversion_site' => $siteId), 'DAY_COUNTERS' => $dayCounters);
}
return $result;
}
示例4: passed
/**
* Возвращает дату в формате прошедшего времени. Например, "15 минут назад", "2 часа назад", "вчера", ...
* @param \Bitrix\Main\Type\DateTime $datetime
* @return string
*/
public static function passed(\Bitrix\Main\Type\DateTime $datetime, $formatDateTime = 'd.m.Y H:i', $formatDay = 'H:i')
{
$time = $datetime->getTimestamp();
$diff = time() - $time;
//
if (self::passedYesterday($time, $output)) {
return $output;
} elseif ($diff < 60) {
return "только что";
} elseif ($diff < 60 * 60) {
return self::passedMinutes(0, $diff);
} elseif ($diff < 60 * 60 * 24) {
return self::passedHours(0, $diff);
} else {
return $datetime->format($formatDateTime);
}
}
示例5: generateInitialData
public static function generateInitialData(Date $from)
{
if (($to = Option::get('conversion', 'START_DATE_TIME', 'undefined')) != 'undefined' && DateTime::isCorrect($to, 'Y-m-d H:i:s') && ($to = new DateTime($to, 'Y-m-d H:i:s')) && $to->format('Y-m-d H:i:s') > $from->format('Y-m-d H:i:s') && Option::get('conversion', 'GENERATE_INITIAL_DATA', 'undefined') == 'undefined') {
Option::set('conversion', 'GENERATE_INITIAL_DATA', 'generated');
$context = new self();
// generate data
$data = array();
foreach (EventManager::getInstance()->findEventHandlers('conversion', 'OnGenerateInitialData') as $handler) {
$result = ExecuteModuleEventEx($handler, array($from, $to));
// TODO validate
foreach ($result as $row) {
$context->id = null;
$context->attributes = array();
$context->setAttributes($row['ATTRIBUTES']);
$context->save();
if ($dayCounters =& $data[$context->id]) {
self::appendDayCounters($dayCounters, $row['DAY_COUNTERS']);
} else {
$dayCounters = $row['DAY_COUNTERS'];
}
}
}
unset($dayCounters);
// save data to database
$numerators = CounterManager::getTypes(array('GROUP' => 'day'));
unset($numerators['conversion_visit_day']);
foreach ($data as $id => $dayCounters) {
$context->id = $id;
foreach ($dayCounters as $day => $counters) {
$day = new Date($day, 'Y-m-d');
$visitSum = 0;
$visitQuantity = 0;
unset($counters['conversion_visit_day']);
foreach ($counters as $name => $value) {
$context->addCounter($day, $name, $value);
if ($numerators[$name]) {
$visitSum += $value;
$visitQuantity += 1;
}
}
$context->addCounter($day, 'conversion_visit_day', $visitQuantity ? round($visitSum / $visitQuantity * 100) + 1 : 1);
}
}
}
}
示例6: FormatDate
/**
* <p>Преобразует дату из одного заданного формата в другой заданный формат. В формате допустимы следующие обозначения:</p> <p> </p> <table width="100%" class="tnormal"> <tr> <th width="40%">Обозначение</th> <th width="60%">Описание</th> </tr> <tr> <td>YYYY</td> <td>Год (0001 - 9999)</td> </tr> <tr> <td>MM</td> <td>Месяц (01 - 12)</td> </tr> <tr> <td>DD</td> <td>День (01 - 31)</td> </tr> <tr> <td>HH</td> <td>Часы (00 - 24)</td> </tr> <tr> <td>MI</td> <td>Минуты (00 - 59)</td> </tr> <tr> <td>SS</td> <td>Секунды (00 - 59)</td> </tr> </table> <p>Динамичный метод.</p>
*
*
* @param string $date Год (0001 - 9999)</b
*
* @param string $format = "DD.MM.YYYY Месяц (01 - 12)</bo
*
* @param H $H День (01 - 31)</b
*
* @param M $I Часы (00 - 24)</bo
*
* @param S $S Минуты (00 - 59)</b
*
* @param $string Секунды (00 - 59)</bod
*
* @param new_forma $t = "DD.MM.YYYY
*
* @param H $H Дата для конвертации.
*
* @param M $I Текущий формат даты. <br>Необязательный. По умолчанию - "DD.MM.YYYY HH:MI:SS".
*
* @param S $S В какой формат необходимо преобразовать. <br>Необязательный. По
* умолчанию - "DD.MM.YYYY HH:MI:SS".
*
* @return string
*
* <h4>Example</h4>
* <pre>
* <?
* // зададим дату
* $date = "31.12.2007";
*
* // укажем формат этой даты
* $format = "DD.MM.YYYY";
*
* // получим формат текущего сайта
* $new_format = CSite::GetDateFormat("SHORT"); // YYYY-MM-DD
*
* // переведем дату из одного формата в другой
* $new_date = $DB-><b>FormatDate</b>($date, $format, $new_format);
*
* // в результате получим дату в новом формате
* echo $new_date; // 2007-12-31
* ?>
*
*
* <?
* // конвертация даты из формата одного сайта в формат другого
*
* // получим формат сайта ru
* $format_ru = CSite::GetDateFormat("SHORT", "ru"); // DD.MM.YYYY
*
* // получим формат сайта en
* $format_en = CSite::GetDateFormat("SHORT", "en"); // YYYY-MM-DD
*
* // переведем дату из формата сайта ru в формат сайта en
* $new_date = $DB-><b>FormatDate</b>($date, $format_ru, $format_en);
*
* // в результате получим дату в новом формате
* echo $date; // 2007-12-31
* ?>
* </pre>
*
*
* <h4>See Also</h4>
* <ul> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/main/reference/cdatabase/dateformattophp.php">CDatabase::DateFormatToPHP</a>
* </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/csite/getdateformat.php">CSite::GetDateFormat</a>
* </li> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/date/convertdatetime.php">ConvertDateTime</a> </li>
* <li> <a href="http://dev.1c-bitrix.ru/api_help/main/functions/date/index.php">Функции для работы с
* датой и временем</a> </li> </ul> <a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/main/reference/cdatabase/formatdate.php
* @author Bitrix
*/
public static function FormatDate($strDate, $format = "DD.MM.YYYY HH:MI:SS", $new_format = "DD.MM.YYYY HH:MI:SS")
{
if (empty($strDate)) {
return false;
}
if ($format === false && defined("FORMAT_DATETIME")) {
$format = FORMAT_DATETIME;
}
$fromPhpFormat = Main\Type\Date::convertFormatToPhp($format);
$time = false;
try {
$time = new Main\Type\DateTime($strDate, $fromPhpFormat);
} catch (Main\ObjectException $e) {
}
if ($time !== false) {
//Compatibility issue
$fixed_format = preg_replace(array("/(?<!Y)Y(?!Y)/i", "/(?<!M)M(?!M|I)/i", "/(?<!D)D(?!D)/i", "/(?<!H)H:I:S/i"), array("YYYY", "MM", "DD", "HH:MI:SS"), strtoupper($new_format));
$toPhpFormat = Main\Type\Date::convertFormatToPhp($fixed_format);
return $time->format($toPhpFormat);
}
return false;
}
示例7: deleteOld
/**
* @param int $days
*
* @return bool
*/
public static function deleteOld($days)
{
$expired = new Main\Type\DateTime();
$expired->add('-' . $days . 'days');
$expiredValue = $expired->format('Y-m-d H:i:s');
/** @var Main\DB\Connection $connection */
$connection = Main\Application::getConnection();
/** @var Main\DB\SqlHelper $sqlHelper */
$sqlHelper = $connection->getSqlHelper();
$sqlExpiredDate = $sqlHelper->getDateToCharFunction("'" . $expiredValue . "'");
if ($connection instanceof Main\DB\MysqlCommonConnection) {
$query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t SELECT ID FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
$connection->queryExecute($query);
$query = "DELETE FROM b_sale_basket\tWHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
$connection->queryExecute($query);
} elseif ($connection instanceof Main\DB\MssqlConnection) {
$query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)";
$connection->queryExecute($query);
$query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t)";
$connection->queryExecute($query);
} elseif ($connection instanceof Main\DB\OracleConnection) {
$query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
$connection->queryExecute($query);
$query = "DELETE FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlExpiredDate . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
$connection->queryExecute($query);
}
return true;
}
示例8: deleteOld
/**
* Delete fuserId over several days.
*
* @param int $days Interval.
* @return void
*/
public static function deleteOld($days)
{
$expired = new Main\Type\DateTime();
$expired->add('-' . $days . 'days');
$expiredValue = $expired->format('Y-m-d H:i:s');
/** @var Main\DB\Connection $connection */
$connection = Main\Application::getConnection();
/** @var Main\DB\SqlHelper $sqlHelper */
$sqlHelper = $connection->getSqlHelper();
$query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < " . $sqlHelper->getDateToCharFunction("'" . $expiredValue . "'") . "\n\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
$connection->queryExecute($query);
}
示例9: deleteOld
/**
* @param int $days
*
* @return bool
*/
public static function deleteOld($days)
{
$connection = Main\Application::getConnection();
$expired = new Main\Type\DateTime();
$expired->add('-' . $days . 'days');
$expiredValue = $expired->format('Y-m-d H:i:s');
if ($connection instanceof Main\DB\MysqlConnection) {
$query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t SELECT ID FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\t\t\t \t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < '" . $expiredValue . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
$connection->query($query);
$query = "DELETE FROM b_sale_basket\tWHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < '" . $expiredValue . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) LIMIT " . static::BASKET_DELETE_LIMIT;
$connection->query($query);
} elseif ($connection instanceof Main\DB\MssqlConnection) {
$query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID IN (\n \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE b_sale_fuser.DATE_UPDATE < CONVERT(varchar(20),'" . $expiredValue . "', 20)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)";
$connection->query($query);
$query = "DELETE TOP (" . static::BASKET_DELETE_LIMIT . ") FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < CONVERT(varchar(20),'" . $expiredValue . "', 20)\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t)";
$connection->query($query);
} elseif ($connection instanceof Main\DB\OracleConnection) {
$query = "DELETE FROM b_sale_basket_props WHERE\n\t\t\t\t\t\t\t\t\t\tBASKET_ID NOT IN (\n \t\t\t\t\t\t\t\t\t\t\tSELECT id FROM b_sale_basket WHERE\n \t\t\t\t\t\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < TO_DATE('" . $expiredValue . "', 'YYYY-MM-DD HH24:MI:SS')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
$connection->query($query);
$query = "DELETE FROM b_sale_basket WHERE\n\t\t\t\t\t\t\t\t\tFUSER_ID IN (\n \t\t\t\t\t\t\t\t\t\tSELECT b_sale_fuser.id FROM b_sale_fuser WHERE\n \t\t\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < TO_DATE('" . $expiredValue . "', 'YYYY-MM-DD HH24:MI:SS')\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\t\t) AND ROWNUM <= " . static::BASKET_DELETE_LIMIT;
$connection->query($query);
}
return true;
}
示例10: deleteOld
/**
* @param $days
*/
public static function deleteOld($days)
{
$connection = Main\Application::getConnection();
$expired = new Main\Type\DateTime();
$expired->add('-' . $days . 'days');
$expiredValue = $expired->format('Y-m-d H:i:s');
if ($connection instanceof Main\DB\MysqlConnection) {
$query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < '" . $expiredValue . "'\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
$connection->query($query);
} elseif ($connection instanceof Main\DB\MssqlConnection) {
$query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < CONVERT(varchar(20),'" . $expiredValue . "', 20)\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
$connection->query($query);
} elseif ($connection instanceof Main\DB\OracleConnection) {
$query = "DELETE FROM b_sale_fuser WHERE\n\t\t\t\t\t\t\t\t\t\tb_sale_fuser.DATE_UPDATE < TO_DATE('" . $expiredValue . "', 'YYYY-MM-DD HH24:MI:SS')\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.USER_ID IS NULL\n\t\t\t\t\t\t\t\t\t\tAND b_sale_fuser.id NOT IN (select FUSER_ID from b_sale_basket)";
$connection->query($query);
}
}