Metodos MONTH como usar ?
Closed this issue · 4 comments
vsalgueiro7 commented
Metodos MONTH como usar ?
vsalgueiro7 commented
como eu usaria essa query
SELECT * FROM despesas
WHERE MONTH(des_vencimento) = MONTH(CURRENT_DATE())
AND YEAR(des_vencimento) = YEAR(CURRENT_DATE())
vsalgueiro7 commented
encontrei .. srs ..
use ClanCats\Hydrahon\Query\Expression as Ex;
hugo-leij commented
Hi @vsalgueiro7
How do you use it?
I got:
$traffic = $h->table('duration_in_traffic_data');
$result = $traffic
->select()
->where(function($q) {
$q->where('datetime', '>=', $_GET['date_from']);
$q->where('datetime', '<=', $_GET['date_to']);
})
->get();
This gives a error:
$traffic = $h->table('duration_in_traffic_data');
$result = $traffic
->select()
->where(function($q) {
$q->where('DATE(datetime)', '>=', $_GET['date_from']);
$q->where('DATE(datetime)', '<=', $_GET['date_to']);
})
->get();
How can u make DATE(datetime) ?
mario-deluna commented
@hugo-leij @vsalgueiro7 You need to mark expressions as expressions otherwise Hydrahon does not know when to not escape your fields:
use ClanCats\Hydrahon\Query\Expression as Ex;
$traffic = $h->table('duration_in_traffic_data');
$result = $traffic
->select()
->where(function($q) {
$q->where(new Ex('DATE(datetime)'), '>=', $_GET['date_from']);
$q->where(new Ex('DATE(datetime)'), '<=', $_GET['date_to']);
})
->get();