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 9188865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:06:54+00:00 2026-06-17T20:06:54+00:00

I am using codeigniter for my php project, but am not much experience in

  • 0

I am using codeigniter for my php project, but am not much experience in it. So, please help me.

I have two database. 1. Kalix2 2. Asterisk

In both the database I am having some table. I want to make a join on the tables from two different database. I have the below query, it’s working fine in back-end, but I don’t know how to implement it using Active record.

SELECT  a.CompanyName, sum(ceil((b.billsec)/(c.Call_Limit*60))) as totalcall,
           hour(b.calldate) as use_hour FROM  Kalix2.ph_Companies a 
           INNER JOIN Asterisk.cdr b ON b.clid LIKE CONCAT('%', a.CompanyName, '%') 
           INNER JOIN Kalix2.ph_Plans c ON c.Comp_ID= a.Comp_ID 
           where  date(b.calldate)>='2013-01-15' and date(b.calldate)<='2013-1-20'  
           and c.Plan_Type='Per_Call' and a.CompanyName='ABCD' 
           group by hour(b.calldate);

Please help me to convert this query into active record format.

  • 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-17T20:06:55+00:00Added an answer on June 17, 2026 at 8:06 pm

    You should be able to convert this to active record if you want but you will gain better performance by just converting this to Query Bindings. Common mistake is trying to run a query off of multiple classes:

    $this->db1
    $this->db2
    

    This will not work because running $this->db1->get() because it is only aware of the data in db1 and not db2. Verbosely keep the database.table info in the joins, use only one db object, and use the profiler to debug the query generation and you should be good.

    Connecting to Multiple Databases

    Active Record Class and Joins

    Debug the query using Profiler

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

Sidebar

Related Questions

I have a PHP project (I'm using CodeIgniter) with data capture. The form is
I'm working on a small project, where I'm using the codeigniter php framework, but
im doing a PHP project using codeigniter 2.1.2 , using mySql database on WAMP,
I'm using CodeIgniter (a PHP framework) to build an app, and I have an
I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
I am on a project using php and codeigniter framework. I want to make
When I decided to start using php framework, I have gone for CodeIgniter because
I am using PHP and the codeigniter framework for a project I am working
I'm working on a new php project with CodeIgniter and I have few questions
I am working on a codeigniter project. I developed it using wampserver locally, but

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.