Работа с SQL

Выбор элементов инфоблока

Выбор номеров дней с новостями из инфоблока:

global $DB, $USER;
$this->db =& $DB;
$this->user =& $USER;
 
$query = "SELECT DISTINCT EXTRACT(DAY FROM `ACTIVE_FROM`) AS `day` FROM `b_iblock_element` WHERE `IBLOCK_ID` = {$this->blockId}
              AND `ACTIVE` = 'Y'
              AND `ACTIVE_FROM` BETWEEN '{$this->dateBegin->format(self::MYSQL_DATETIME_FORMAT)}' AND '{$this->dateEnd->format(self::MYSQL_DATETIME_FORMAT)}'";
 
$this->CDatabaseRes = $this->db->Query($query, false, '');
$results = array();
if ($this->CDatabaseRes->SelectedRowsCount() > 0) {
  while ($ar_props = $this->CDatabaseRes->Fetch()) {
    $results[] = $ar_props['day'];
  }
}
 
return $results;