C3rd
Fastest way to connect to DB with existing .env
Posted: 10 Jul 2024, 14:34pm - Wednesday
Several projects now I ended up to create a standalone script to do specific task. Loading doctrine would be using lots of resources. I always want to create a lite-weight script to do specific tasks but connecting to the DB is a bit tricky when you are in a framework (symfony + doctrine).
$connection = $_ENV['DATABASE_URL'];
list(
$driver,,, $username, $password,
$host, $port, $db_name, $extra1
) = preg_split('/(:|\/|@|\?|&)/', $connection);
$sql = new xSQL([
'driver' => $driver,
'port' => $port,
'database' => $db_name,
'host' => $host,
'username' => $username,
'password' => $password
], true);
This is how I do it.. Helps a lot doing this way.
Search
Categories
Related Links
- Apache Web Server
- ASP Immigration Services Ltd.
- CentOS Linux
- Color Scheme Picker
- CSS Button Generator
- Deviant Art Account
- Don Tabaniag - GraphiCult
- Jerson Maglasang Weblog
- Joshua Manlunas
- Mark "mungkey" Vicente
- Matt Arnilo Baluyos
- MySQL
- Paul Labis
- PHP
- PrendStar
- Ridvan Baluyos
- Scott Davies
- SEO Fart XML-RPC Ping Tool
- Stripes Generator
- The Hero
- Ubuntu Linux
- Vim Carlo Nabora (DA)
- Wella Maria Hong
- What is my IP?
- Xavier University - Ateneo de Cagayan
- Zabyer Community