3
In the Mysql I have saved a person’s birth date, I need to assemble a query that return me the birthday of the week, those who make today’s birthday to today + 7 days.
I’m trying like this:
//Metodo da tela de listagem
public function birthdayDeed()
{
    // construtor de query
    $criteria = CriteriaBuilder::create()
    // seleciono a tabela
        ->tables('clients')
    // adiciono uma condição da data ser maior ou igual a de hoje
        ->_and('birth', '>=', date('Y-m-d', time()))
    // E se data for menor ou igual daqui a 7 dias
        ->_and('birth', '<=', date('Y-m-d', strtotime("+7 days"))); 
    $this
        ->title( Language::get('client', 't-birthday') )
        ->view('client', 'list')
        ->attr('clients', $this->toArray( (new Client())->debug()->listAll(null, $criteria) ))
        ->display();
}
Which results in the query:
'SELECT * FROM  clients   WHERE birth >=  :birth  AND birth <= :birth1;'
I know where the error is occurring, I’m also comparing the year, so would be for example:
birth: 1996-10-30
condição: 1996-10-30 >= 2016-10-28 AND 1996-10-30 <= 2016-11-04
Soon I would never enter this condition, I need to know how to compare only the day and month, someone could help?
In mysql use the function
day()andmonth()to compare specific pieces of a date.– rray
I’d like to know that
CriteriaBuilderis a package, or is it from some framework, if you can say! thank you.– novic
@Virgilionovic is from a microframework I did to do my projects, I have it on Github, but it’s incomplete, missing some commits with bug fixes: https://github.com/legionlab/troubadour
– Leonardo
@Very cool ivcs I’ll take a look
– novic