<?php
class A
{
protected $sql = null;
public function setSQL()
{
$this->sql = "SELECT * FROM users WHERE id = 123";
return $this;
}
public function getSQL()
{
return $this->sql;
}
}
class B extends A
{
public function addSQL()
{
$this->sql .= " AND name = 'Alex'";
return $this;
}
}
$a = new A();
$b = new B();
echo $b->setSQL()->addSQL()->getSQL();