_getSelfMysql(), 't_fragment_pool', array( 'type' => $type, 'fragment_type' => $fragmentType, 'alloc_time' => $allocTime, ) ); $items = array(); if ($rows) { foreach ($rows as $row) { if ($row['fragment_num'] > 0) { array_push($items, $row); } } } return $items; } private static function decNum($itemId) { $allocTime = self::getAllocTime(); SqlHelper::update (myself()->_getSelfMysql(), 't_fragment_pool', array( 'fragment_id' => $itemId, 'alloc_time' => $allocTime, ), array( 'fragment_num' => function () { return 'GREATEST(0, fragment_num - 1)'; }, 'alloced_num' => function () { return 'alloced_num + 1'; } ) ); } private static function getAllocTime() { $allocTime = myself()->_getNowDaySeconds() + intval((myself()->_getNowTime() - myself()->_getNowDaySeconds()) / 3600) * 3600; return $allocTime; } }