[RESOLVED] Fatal error: Call to a member function prepare() on a non-object - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: [RESOLVED] Fatal error: Call to a member function prepare() on a non-object

  1. #16
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,692
    You could make a general method to get all the properties as an array (maybe using get_object_vars?) so that the client code can pick and choose what it needs when it needs it.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  2. #17
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    2,242
    I wouldn't put playlength in the shopproduct class because its not a constant property (like bookproduct doesn't use it). Instead it should only be part of the CDProduct Class, since this is the only one that uses it. To make the parent class more generic, you could initialize it instead of using a bunch of arguments to the constructor (which is generally bad design anyway) but instead with an array, like:

    PHP Code:
    public function __construct(array $props) {
        foreach (
    $props as $name => $value) {
            if (
    property_exists($this$name)) {
                
    $this->$name $value;
            }
        }

    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •