I'm not sure how to represent this scenario in a UML class diagram.
An example of what I mean:
A typical Mysql class which handles the DB connection, but delegates the statement construction and execution to another class called MysqlStatement, so that the Mysql class has one method called Mysql::prepare() which returns the Mysqlstatement class (not containing it), like so:
class Mysql extends DB_Connection {
public function connect($user, $pass, $dbhost, $dbname)
{
$this->dbh = mysql_connect($dbhost, $user, $pass);
// ...
}
/**
* Connects to the DB, then creates and returns the statement object
* @param string $query
* @return MysqlStatement
*/
public function prepare($query)
{
if (! $this->dbh) $this->connect();
return new MysqlStatement($this->dbh, $query);
}
}
Note that, as far as I know, there's no composition/aggregation/association, because no class contains the other. So I'm not sure how to represent this relationship. I need to do it to put everything in order and get a glimpse of the system.