Jump to content

Search the Community

Showing results for tags 'late static binding'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. picokojama

    OOP error

    Hi everyone, I have something like more advanced problem, so I hope someone will help. No need for looking for variables and functions matches, I have good editor, and if there is any, it is because I am translating code to english. Here I have class DBobject, which contains all common database methods, but my focus is on two: public static function find_by_sql($sql) { global $pdo; // pdo connection works fine $query = $pdo->query($sql); $object_array = array(); while($row = $query->fetchAll()) { $object_array[] = static::instantiate($row); } return $object_array; } public static function instantiate($row) { $class = get_called_class(); $object = new $class; // because it can be used for users, pages... I don't wont to repeat my code foreach ($row as $attribute => $value) { $object->$attribute = $value; } return $object; } It is parent class of many classes, and I am looking in the class Comments protected static $table_name='komentari';protected static $db_fields=array(// all of my fields are here);public $id;public $user_id;// and all of database fields as variables And now, when I want to call it... $comment = Comment::find_by_sql(// here I select user based upon id); // this should return object with attributes from my database (because I returned object in instantiate function), am I right?echo $comment->content; // I exept here to echo lorem ipsum dolor sit amet.... And I get error that I called attribute of non-object $comment, aldo I returned the object in instantiate method
×
×
  • Create New...