This topic is locked

Custom query on table from other database

11/2/2016 4:03:05 PM
PHPRunner General questions
snuffi01 author

I need to use the "View as"-"Custom Code" on the list page to show number of agents from an table witch isnt in the default database of the PHPRunner project.

How can i do that?

My code on the "View as"-"Custom"

$sql = "select

count(agent_id) AS agenter,


from grp_agent

WHERE group_id = $value

Group BY group_id";
$rs = CustomQuery($sql);

$data = db_fetch_array($rs);


As my "other" database is named ecc i have tried with

from ecc.grp_agent

But as that doesnt work (Table 'ecc.grp_agent' doesn't exist) i guess that its not that simple?

Sergey Kornilov 11/2/2016

You cannot do just that because connection in PHP code is made to specific database. You have two options here:

  1. In your code open a connection to another database and retrieve data
  2. Or in Enterprise Edition of PHPRunner you can add a connection to second database and retrieve data using DAL functions: