Вверх ↑
Ответов: 1528
Рейтинг: 57
#1: 2013-09-17 11:40:14 ЛС | профиль | цитата
кому интересно, вот чем закончилось
php

#php
function getLastRollers($date) {
$date_ex = explode('-', $date); // 17-08-2013
$date_ex[0] = (int) $date_ex[0];
$date_ex[1] = (int) $date_ex[1];
$date_ex[2] = (int) $date_ex[2];
$sql = "SELECT roller_id FROM rules_month WHERE ((month_num >= $date_ex[1] AND month_year = $date_ex[2]) OR month_year > $date_ex[2]) AND (";
$init = true;
for ($index_day = (int)$date_ex[0]; $index_day <= 31;$index_day++) {
if ($init) {
$init = false;
$sql = $sql . getLike($index_day, 'month_days');
} else {
$sql = $sql . " OR" . getLike($index_day, 'month_days');
}
}
$sql = $sql . ")";
return $sql;
}
функция которая генерит это
sql

#sql
SELECT roller_id FROM rules_month WHERE ((month_num >= 8 AND month_year = 2013) OR month_year > 2013) AND (
(month_days LIKE '17,%' OR month_days LIKE '%,17,%' OR month_days LIKE '%,17' OR month_days = '17') OR
(month_days LIKE '18,%' OR month_days LIKE '%,18,%' OR month_days LIKE '%,18' OR month_days = '18') OR
(month_days LIKE '19,%' OR month_days LIKE '%,19,%' OR month_days LIKE '%,19' OR month_days = '19') OR
(month_days LIKE '20,%' OR month_days LIKE '%,20,%' OR month_days LIKE '%,20' OR month_days = '20') OR
(month_days LIKE '21,%' OR month_days LIKE '%,21,%' OR month_days LIKE '%,21' OR month_days = '21') OR
(month_days LIKE '22,%' OR month_days LIKE '%,22,%' OR month_days LIKE '%,22' OR month_days = '22') OR
(month_days LIKE '23,%' OR month_days LIKE '%,23,%' OR month_days LIKE '%,23' OR month_days = '23') OR
(month_days LIKE '24,%' OR month_days LIKE '%,24,%' OR month_days LIKE '%,24' OR month_days = '24') OR
(month_days LIKE '25,%' OR month_days LIKE '%,25,%' OR month_days LIKE '%,25' OR month_days = '25') OR
(month_days LIKE '26,%' OR month_days LIKE '%,26,%' OR month_days LIKE '%,26' OR month_days = '26') OR
(month_days LIKE '27,%' OR month_days LIKE '%,27,%' OR month_days LIKE '%,27' OR month_days = '27') OR
(month_days LIKE '28,%' OR month_days LIKE '%,28,%' OR month_days LIKE '%,28' OR month_days = '28') OR
(month_days LIKE '29,%' OR month_days LIKE '%,29,%' OR month_days LIKE '%,29' OR month_days = '29') OR
(month_days LIKE '30,%' OR month_days LIKE '%,30,%' OR month_days LIKE '%,30' OR month_days = '30') OR
(month_days LIKE '31,%' OR month_days LIKE '%,31,%' OR month_days LIKE '%,31' OR month_days = '31') )
карма: 0

0