MYSQL Fetch By Year and Month

::Count by Year and Month
SELECT YEAR(`date`) as year_val, MONTH(`date`) as month_val ,COUNT(*) as total
FROM news
GROUP BY YEAR(`date`), MONTH(`date`)
ORDER BY year_val desc, month_val asc;

::Fetch By Year and Month
SELECT * FROM news WHERE MONTH(`date`) = 10 and YEAR(`date`) = 2011;

Doctrine Record Fetch Event

public function postHydrate($event) {
parent::postHydrate($event);
$invoker = $event->data;

$array = array(“to_json”,”type”,”product_ids”);
foreach($array as $arr){
if(isset($invoker->$arr))
$invoker->$arr = Zend_Json::decode($invoker->$arr);
}

}

Mysql Double Date Duration Fetch intersection

|————————————| search set duration
album date duration
x |—-|
o |——————|
o |——————————————————|
o |————|
o |—————————————-|
x |—-|

SET @s_date = CURDATE();
SET @duration = 0;

SELECT * FROM albums
WHERE
album_date – INTERVAL album_date_duration DAY BETWEEN @s_date – INTERVAL @duration DAY and @s_date + INTERVAL @duration DAY
OR
album_date + INTERVAL album_date_duration DAY BETWEEN @s_date – INTERVAL @duration DAY and @s_date + INTERVAL @duration DAY
OR
(
album_date – INTERVAL album_date_duration DAY = @s_date + INTERVAL @duration DAY
)