AnsweredAssumed Answered

Can't use global $db in my custom php page

Question asked by aravinth on Jan 28, 2016
Latest reply on Jan 31, 2016 by Sohan Tirpude

I just create the custom php page inside include folder, then i want to call that page using ajax request. I need to access the database in that page, for access database  i use

global $db;
$query = "SELECT * from users where id='$user_id'";
$result = $db->query($query);
var_dump($result);

 

the result never printed.

 

And also i just try like below

 

require_once('../SugarObjects/SugarConfig.php');
require_once('../database/DBManagerFactory.php');
$query = "SELECT * from users where id='$user_id'";

$db = DBManagerFactory::getInstance();
$result = $db->query($query);
var_dump($result);

 

now it says no access entry point.

 

How can i get the database result in my custom php page inside include folder.

Outcomes