/**
  * return records for current month, there is mandatory field `Day` - a day for current row
  * use the following class variables to pass to your database query 
  * $this->iYear, $this->iMonth, $this->iNextYear, $this->iNextMonth
  *
  * for example:
  * 
  * return $db->getAll ("
  *  SELECT *, DAYOFMONTH(FROM_UNIXTIME(`Blogstart`)) AS `Day`
  *  FROM `my_table`
  *  WHERE `Date` >= UNIX_TIMESTAMP('{$this->iYear}-{$this->iMonth}-1') AND `Date` < UNIX_TIMESTAMP('{$this->iNextYear}-{$this->iNextMonth}-1') AND `Status` = 'approved'");
  *
  */
 function getData()
 {
     switch ($this->sMode) {
         case 'dor':
             return db_res_assoc_arr("\r\n\t\t\t\t\tSELECT `Profiles`.*, DAYOFMONTH(`Profiles`.`DateReg`) AS `Day`\r\n\t\t            FROM `Profiles`\r\n\t\t            WHERE\r\n\t\t\t\t\t\tUNIX_TIMESTAMP(`Profiles`.`DateReg`) >= UNIX_TIMESTAMP('{$this->iYear}-{$this->iMonth}-1')\r\n\t\t\t\t\t\tAND UNIX_TIMESTAMP(`Profiles`.`DateReg`) < UNIX_TIMESTAMP('{$this->iNextYear}-{$this->iNextMonth}-1')\r\n\t\t\t\t\t\tAND `Profiles`.`Status` = 'Active'\r\n\t\t\t\t");
         case 'dob':
             $aWhere[] = "MONTH(`DateOfBirth`) = MONTH(CURDATE()) AND DAY(`DateOfBirth`) = DAY(CURDATE())";
             return db_res_assoc_arr("\r\n\t\t\t\t\tSELECT `Profiles`.*, DAYOFMONTH(`DateOfBirth`) AS `Day`\r\n\t\t            FROM `Profiles`\r\n\t\t            WHERE\r\n\t\t\t\t\t\tMONTH(`DateOfBirth`) = MONTH('{$this->iYear}-{$this->iMonth}-1') AND\r\n\t\t\t\t\t\t`Profiles`.`Status` = 'Active'\r\n\t\t\t\t");
     }
 }
Example #2
0
 function getSearchDataByParams($aParams = '')
 {
     $aSql = array('ownFields' => '', 'joinFields' => '', 'order' => '');
     // searchFields
     foreach ($this->aCurrent['ownFields'] as $sValue) {
         $aSql['ownFields'] .= $this->setFieldUnit($sValue, $this->aCurrent['table']);
     }
     // joinFields & join
     $aJoins = $this->getJoins();
     if (!empty($aJoins)) {
         $aSql['ownFields'] .= $aJoins['ownFields'];
         $aSql['joinFields'] .= $aJoins['joinFields'];
         $aSql['join'] = $aJoins['join'];
         $aSql['groupBy'] = $aJoins['groupBy'];
     } else {
         $aSql['ownFields'] = trim($aSql['ownFields'], ', ');
     }
     // from
     $aSql['from'] = " FROM `{$this->aCurrent['table']}`";
     // where
     $aSql['where'] = $this->getRestriction();
     // limit
     $aSql['limit'] = $this->getLimit();
     // sorting
     $this->setSorting();
     $aSort = $this->getSorting($this->aCurrent['sorting']);
     foreach ($aSort as $sKey => $sValue) {
         $aSql[$sKey] .= $sValue;
     }
     // rate part
     $aRate = $this->getRatePart();
     if (is_array($aRate)) {
         foreach ($aRate as $sKey => $sValue) {
             $aSql[$sKey] .= $sValue;
         }
     }
     // execution
     $sqlQuery = "SELECT {$aSql['ownFields']} {$aSql['joinFields']} {$aSql['from']} {$aSql['join']} {$aSql['where']} {$aSql['groupBy']} {$aSql['order']} {$aSql['limit']}";
     //echoDbg($sqlQuery);
     $aRes = db_res_assoc_arr($sqlQuery);
     return $aRes;
 }