O'Reilly logo

PHP Application Development with NetBeans Beginner's Guide by M A Hossain Tonu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — creating the BaseDao class

To use with a database connection, we will keep the database access credentials as their own class constants. Also, we will use PDO for all sorts of database operations. To create the Base class, go through the following steps:

  1. Create a new PHP file inside the Dao directory named BaseDao.php, and type in the following class:
    <?php
    namespace My\Dao;
    abstract class BaseDao {
    private $db = null;
    const DB_SERVER = "localhost";
    const DB_USER = "root";
    const DB_PASSWORD = "root";
    const DB_NAME = "user";
    }
    ?>
    

    You can see that this class uses namespace My\Dao;, and there is also an abstract keyword before the class name, which defines the class as abstract. This means that the class cannot be instantiated or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required