Jump to content

[SOLVED] classes


popcornplya

Recommended Posts

Then its not extending the classes, its just simply used within them. eg;

 

<?php

class foo {

  private $db;

  function __construct() {
    require_once 'yourdbclass.class.php';
    $this->db = new yourdbclass;
  }

  function usedbclass() {
    $sql = "SELECT * FROM tbl";
    return $this->db->query($sql);
  }

}

?>

Link to comment
Share on other sites

well, what do you mean by wanting it to "work?"

 

You are asking for the best way for one class to "inherit" another class.  You need to be a lot more specific with your scenario than how you're being now, if you want any meaningful answers.  Depending on what you are wanting to do, you may just need to instantiate an object of your database class, and use that in your new class.  Or your situation may call for extending the database class.  Or you may end up needing to bust out with an interface.  Who knows? Without details, we cannot give you any good advice.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.