0

Please what are the default numbers of php pages need to be created for database relation in managing a dynamic website? Eg: admin.php, delete.php etc

4
Contributors
8
Replies
22
Views
4 Years
Discussion Span
Last Post by homeboy
0

All depends on the structure of your file and your logical of programming. Personaly, the basic are 4 pages (index.php, base.php is for connexion class, derive.php & param.inc.php)
index.php

require('*.php');
  require('*.php');
  include_once('*.inc.php');

  $mysqli = new mysqli(MYHOST, MYUSER, MYPASS, BASE);
  $objDerive = new Derive(***);

  $objDerive->X(***);

base.php

class Base
  {
      /* DECLARATION DES METHODES */
       public function connex()
      {
          /* STYLE ORIENTE OBJET */
          if (mysqli_connect_errno()) {
              printf("Échec de la connexion : %s\n", mysqli_connect_error());
              exit();
          }
      }
  }//Fin de Classe

derive.php

require_once('clsbase.php');

  class Derive extends Base
  {
      //DECLARATION DES DATAS MEMBRES
      protected $1;
      protected $2;

      //DECLARATION DES METHODES
      function __construct() //ctor.
      {
      }

      public function add()
      {
         ***
      }

      public function update()
      {
         ***
      }

      public function del()
      {
        ***
      }
  }//FIN Cls.

param.inc.php

define("MYHOST","localhost");
  define("BASE","*");
  define("MYUSER","*");
  define("MYPASS","*");

Edited by homeboy: update

0

Although I do not understand why, I still wonder why you are creating classes, but use the procedural version of mysqli... makes no sense to me. It's probably me... I'll drop it, too off-topic.

0

Pritaeas, I use the object-oriented version of MySQLi. I also wrap my connection to MySQL within my own Database class. It gives me the freedom to do some things I need to do everytime a query is executed, such as determine which database server the query should be sent to.

0

@Dani: Yes, I understand why you would want to do that (because it makes sense to encapsulate the class). But that's not what homeboy's doing.

0

Oops! My mistake. I didn't check what I wrote in my code. What I would like to say is: I usally use class Base for connexion to Server. In this case class Base is useless.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.