0

How to get values count in db_select My query is:

$last_item = '2015-07-19';
$query = db_select('field_data_appointment_date','ap');
$query->join('field_data_appointment_slot','aps','aps.entity_id = ap.entity_id');
$query->fields('aps',array('appointment_slot_value '));
$query->condition('ap.appointment_date_value', '%' . db_like($last_item) . '%', 'LIKE');
$result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
dsm($result);

and my result is:

... (Array, 4 elements)
0 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 10.00-11.00
1 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 10.00-11.00
2 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 10.00-11.00
3 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 11.00-12.00

I need result like count of

:10.00-11.00 is 3
:11.00-12:00 is 1

Anyone help me out

1
  • What do you want to do? Give more details. maybe non straight query on Database solution exists.
    – M a m a D
    Commented Jul 19, 2015 at 7:21

1 Answer 1

0

Not fully understanding the output you really want to achieve, but here's examples on how to count the results coming from the database

get count with db_select

OR

rowCount

Let me know if any of those work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.