Hydrahon
Hydrahon copied to clipboard
Metodos MONTH como usar ?
como eu usaria essa query
SELECT * FROM despesas WHERE MONTH(des_vencimento) = MONTH(CURRENT_DATE()) AND YEAR(des_vencimento) = YEAR(CURRENT_DATE())
encontrei .. srs ..
use ClanCats\Hydrahon\Query\Expression as Ex;
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) ?
@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();