How to access the database in the Suitecrm

Hi Everyone…

I have create the filed name treeapi.php in the root of the suitecrm file folder…
in that i am writing some queries and i need to access db…for that
i need this configurataion

$db_config = [
‘db_host_name’ => ‘localhost’,
‘db_host_instance’ => ‘SQLEXPRESS’,
‘db_user_name’ => ‘iugiuiu’,
‘db_password’ => ‘jvjvyu@00’,
‘db_name’ => ‘demo’,
‘db_type’ => ‘mysql’,
];

** $dsn = “{$db_config[‘db_type’]}:host={$db_config[‘db_host_name’]};dbname={$db_config[‘db_name’]}”;
$pdo = new PDO($dsn, $db_config[‘db_user_name’], $db_config[‘db_password’]);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
**
this is and all needed? unncessary right
i am also user globals $db to access this is correct or how to access the db in this manner…

Don’t know what you’re trying to do here. Maybe below doc will help you:

Hi,
The simple step can be to include

include\database\MysqliManager.php

in your file and then you can play with the queries like you are inside SuiteCRM.

If this looks difficult to you then please add

config.php

and use the dbconfig array and connect with the DB via core PHP PDO.

Thanks