Strict standards: Non-static method dataobject::connect() should not be called statically in C:\wamp\www\verano\bases\book_club\member.class.php on line 39
Strict standards: Non-static method dataobject::disconnect() should not be called statically in C:\wamp\www\verano\bases\book_club\member.class.php on line 58
Lo de que no debería ser llamado el método static no lo entiendo, He comentado los metodos que son ,el script es este:
delphi
<?php require_once "dataobject.class.php"; class member extends dataobject { protected $data = array ( "id" => "", "username" => "", "password" => "", "firstname" => "", "lastname" => "", "joindate" => "", "gender" => "", "favoritegenre" =>"", "emailaddress" => "", "otherinterests" => "" ); private $_genres = array ( "crime" => "Crime", "horror" => "Horror", "thriller" => "Thriller", "romance" => "Romance", "scifi" => "Sci-fi", "adventure" => "Adventure", "nonfiction" => "Non-Fiction" ); // Este es el que da problemas public static function getmembers ($startrow, $numrows, $order) { $conn = parent::connect (); $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . TBL_MEMBERS . " ORDER BY $order LIMIT :startrow, :numrows"; try { $st = $conn->prepare($sql); $st -> bindvalue (":startrow", $startrow, PDO::PARAM_INT); $st -> bindvalue (":numrows", $numrows, PDO::PARAM_INT); $st -> execute (); $members = array (); foreach ($st -> fetchall () as $row){ $members [] = new member ($row); } $st = $conn ->query ("SELECT found_rows () as totalrows"); $row = $st -> fetch (); parent::disconnect ($conn); return array ($members, $row["totalrows"]); } catch (PDOException $e) { parent::disconnect ($conn); die ("Query failed : " . $e->getmessage()); } } // Este es el otro public static function getmember ($id) { $conn = parent::connect (); $sql = "SELECT * FROM " . TBL_MEMBERS . " WHERE id = :id"; try { $st = $conn->prepare ($sql); $st ->bindvalue (":id", $id, PDO::PARAM_INT); $st ->execute (); $row = $st->fetch (); parent::disconnect ($conn); if ($row) return new member ($row); } catch (PDOException $e){ parent::disconnect ($conn); die ("Query failed: " . $e->getmessage ()); } } public function getgenderstring () { return ( $this->data["gender"] == "f" ) ? "Female" : "Male"; } public function getfavoritegenrestring () { return ( $this->_genres[$this->data["favoritegenre"]]) ; } }
Como veis apunta a una clase abstracta que esta en otro archivo, es este:
delphi
<?php require_once "config.php"; // Esta la clase a la que apunta abstract class dataobject { protected $data = array (); public function __construct ($data) { foreach ($data as $key => $value){ if (array_key_exists ($key, $this->data) ) $this-> data[$key] =$value; } } public function getvalue ($field) { if (array_key_exists ($field, $this->data) ) { return $this->data[$field]; } else { die ("Field not found"); } } public function getvalueencoded ($field) { return htmlspecialchars ($this->getvalue($field) ); } protected function connect () { try { $conn = new PDO (DB_DSN, DB_USERNAME, DB_PASSWORD); $conn -> setattribute (PDO::ATTR_PERSISTENT, true); $conn -> setattribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die ("Connection failed: " . $e->getmessage () ); } return $conn; } protected function disconnect ($conn) { $conn = ""; } } ?>
Claro viendo el error, he probado a quitar static de los métodos, pero me sigue devolviendo el mismo fallo.