Doctrine is the most effective way of database connection for PHP projects
Doctrine is a Database middleware for PHP, it uses Object Relational Mapper (ORM) and Database Abstraction Layer (DBAL) to securely and effectively interact withDatabase from your Code. This codes, which I have written, will give you the very basics of how to setup and use Doctrine in your simple PHP projects. To learn more you should refer to https://www.doctrine-project.org
- To install run composer install
packages/bin/doctrine orm:schema-tool:create
-
you can add/modify your entities at src/ and can run packages/bin/doctrine orm:schema-tool:update --force
-
to check what the sql generated packages/bin/doctrine orm:schema-tool:update --force --dump-sql
-
once database structure created you need to enter some data in your DB: php createUser.php yourname and php createBug.php bugdesc 1
-
once you populated data you can can now run the doctrine queries/methods
- _php findUser.php 1 _
- _php findByUser.php yourname _
- _php findAllDQL.php _
- _php findByPagination.php _
- _php findNativeQuery.php _
Read more @ courtesy : [Doctrine project|https://www.doctrine-project.org]