skip to Main Content

A table called api_call_data is being used in a seperate database (done by the original code author, not me) which is located in another server in our Laravel project (I can’t move the table).

Due to that, the original query doesn’t work anymore. The original query was like below:

$apicallData->addSelect(DB::raw("
    (SELECT MAX(`reg_time`) FROM `api_call_data` as A WHERE `A`.`app_id` = `apps_data`.`app_id` and reg_time between $request->from_date and $request->to_date) as api_reg_time
"))

(I have omitted the rest of the queries after this here)

Is there any way to make this original query work? I really wanted to make this work but I am totally lost here.

2

Answers


  1. Chosen as BEST ANSWER

    sorry about my poor knowledge about this.
    I just found out I cannot use different connections in that way.
    I had to change the whole queries to get the data that I need.


  2. You should add another connection on the .env file (or config/database.php, depends on your laravel version) and use that connection in your query. You can refer to this answer for better explaination.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search