Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- trait DatabaseInsert {
- public function insert() {
- echo "{$this->getDb()} insert\n";
- }
- }
- trait DatabaseUpdate {
- public function update() {
- echo "{$this->getDb()} update\n";
- }
- }
- trait DatabaseDelete {
- public function delete() {
- echo "{$this->getDb()} delete\n";
- }
- }
- class Database {
- private $db = null;
- public function __construct() {
- $this->db = 'DB Resource';
- }
- public function getDb() {
- return $this->db;
- }
- }
- class OnlyInsert extends Database {
- use DatabaseInsert;
- }
- $db = new OnlyInsert();
- $db->insert(); // DB Resource insert
- $db->update(); // PHP Fatal error: Uncaught Error: Call to undefined method OnlyInsert::update() in test.php:37
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement