Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7771557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:40:52+00:00 2026-06-01T16:40:52+00:00

table name = call Table structure: user_id | call_time | call_type| Let’s populate it

  • 0
table name  =  call

Table structure:

user_id | call_time | call_type| 

Let’s populate it for understanding

user_id | call_time                   | call_type| 
  0     2012-04-05 07:40:58 GMT+05:00     Mised 
  0     2012-04-06 08:58:45 GMT+05:00     Out 
  0     2012-04-08 09:40:58 GMT+05:00     Incom 

What I want to do

I need Mysql or equivalent Zend Framework query

  1. sum of of call_type.that is I need to know how many there are Out or Missed or Income in each day.

  2. how many call_time exists in each day.that is lets say I have 2012-04-05 so how many time its in database.

I need multi-dimensional array like

i =  start from first  day of the month and go up to last day of current month,

i(2012-04-01) for understanding

Array
(
[ i (2012-04-01)]=>Array
    (
    [Mised ] = 67(sum of all Missed call in this date)
    [Out ] = 10(sum of all out call in this date)
    [Incom ] = 10(sum of all Incom call in this date)
    [total_call] =87 (Sum Of All)
    )

 [ i (2012-04-02) ]=>Array
    [Mised ] = 17(sum of all Missed call in this date)
    [Out ] = 2(sum of all out call in this date)
    [Incom ] = 4(sum of all Incom call in this date)
    [total_call] =23 (Sum Of All)
    )
 .
 .
 .
 .
 .
 .
 .
 .
 .
 [2012-04-30(last day current month)]=>Array
    (
    [Mised ] = 77(sum of all Missed call in this date)
    [Out ] = 72(sum of all out call in this date)
    [Incom ] = 24(sum of all Incom call in this date)
    [total_call] =173 (Sum Of All)
    )

lets say i get total record mean dates that is(2012-04-13 , 2012-04-17 , 2012-04-23 ,2012-04-27 , 2012-04-29)
so my array will start from 2012-04-01 as this is not found in my result so for that my array will be

[2012-04-01]=>Array
    (
    [Mised ] = 0
    [Out ] = 0
    [Incom ] = 0
    [total_call] = 0 

and for (2012-04-13)
array will be

[2012-04-01]=>Array
    (
    [Mised ] = 10
    [Out ] = 55
    [Incom ] = 9
    [total_call] = 74 
    )

what i have tried =

public function Get_Calllogs_For_Graph($user_id, $phone_service_id){

    $curdate = new DateTime(date('Y-m-d')); 
    $current_month = date("m");
    $start_date =    date("Y-$current_month-01");
    $start_date =  $curdate->format("Y-$current_month-d H:i:s");
    $curdate = new DateTime(date('Y-m-d')); 
    $curr_date =  $curdate->format('Y-m-d H:i:s');

    $DB = Zend_Db_Table_Abstract::getDefaultAdapter();
    $select = $DB->select()
                            ->from('call', array('*', 'CAST(call_time AS DATE) AS call_time '))
                                    ->where('phone_service_id = ?', $phone_service_id)
                                    ->where('user_id = ?', $user_id)
                                    ->where(" call_time >= ?",  $start_date)
                                    ->where(" call_time<= ?",  $curr_date);
                                        $select = $DB->fetchAssoc($select);


    $records = array('Outgoing' => array(), 'Incoming' => array(), 'Missed' => array() );               
    if(count($select)){
        foreach($select as $sel){

                if(!array_key_exists($sel['call_name'], $records[$sel['call_type']])){
                    $records[$sel['call_type']][$sel['call_name']] = $this->Get_Calllogs_By_Callname($user_id, $phone_service_id, $start_date, $curr_date, $sel['call_name'], $sel['call_type']);
                }

        }
    }
    echo '<pre>';
    print_r($records);
    echo '</pre>';

    }
public function Get_Calllogs_By_Callname($user_id, $phone_service_id, $start_date, $curr_date, $call_name, $call_direction){

        $DB = Zend_Db_Table_Abstract::getDefaultAdapter();
        $select = $DB->select()
                ->from('call_log', array('COUNT(*) AS total', 'CAST(call_name AS DATE) AS call_name'))
                        ->where('phone_service_id = ?', $phone_service_id)
                        ->where('user_id = ?', $user_id)
                        ->where('call_type= ?', $call_type)
                        ->having('call_name = ? ', $call_name);
                        //->where("call_type>= ?",  $start_date)
                        //->where("call_type<= ?",  $curr_date);

                            $select = $select->query()->fetchAll();
                            if(count($select)){

                                return $select[0]['total'];

                            }else{
                                return 0;
                            }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:40:53+00:00Added an answer on June 1, 2026 at 4:40 pm
    select call_time, call_type, count(*) as num_by_type from db
    group by YEAR(call_time), MONTH(call_time), DAY(call_time), call_type.
    

    so you have the sum for each call_type per day (means max 3 entries per day).

    Then it shouldn’t be too hard for you to make an array per day, total sum being the sum of the sums of the three types (num_by_type).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a tiny model (let's call it Node) that represents a tree-like structure.
I have one table of items, let's call it ITEMS. Now I need to
@Entity @Table(name = BOOKTEST) @NamedQueries({@NamedQuery(name = Booktest.findAll, query = SELECT b FROM Booktest b),
Is table name prefix for fields to be update not allowed in SQL ?
based on the following table Name --------- A A A B B C C
I have a table name KHA_ID with a column name of KHA_ID. I went
I have this table : Name | money_earned _______________________ john | 100 paul |
SQL Server: Table Name : Dad Fields: Id Table Name : Mom Fields: Id
OLEDB source table Name,Age,Seq Gauraw,30,1 Gauraw,31,1 Kiran,28,3 Kiran,29,3 kiran,28,3 Venkatesh,,4 Venkatesh,28,4 I want OLEDB
I have a script that takes a table name and generates a control file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.