it's not "purely procedural": it's focused on the PDO / PDOStatement objects.
Mappers are generally "object-oriented," but that's not the problem they are intended solve. (They solve the problem of relational databases not being object-oriented.)
They do encapsulate everything, though, which I think is what you're looking to accomplish.
class myStmtPDO extends PDO{
# container for prepared statements
protected $_stmt = [];
// . . .
# just do:
# $DB = new myStmtPDO( $your_dsn ); $DB->selectImageData( $_GET['id'],$type,$lob );
public function selectImageData( $id,&$type,&$lob ){
# statement already prepared?
if( empty( $this->_stmt[__METHOD__] ) || ! ($this->_stmt[__METHOD__] instanceof PDOStatement) ){
$sSQL = "SELECT `contenttype`,`imagedata` FROM `image` WHERE `id`=?";
$this->_stmt[__METHOD__] = $this->prepare( $sSQL );
}
# get statement and execute
$stmt = $this->_stmt[__METHOD__];
$stmt->execute( [$id] );
# bind params
$stmt->bindColumn(1, $type, PDO::PARAM_STR, 256);
$stmt->bindColumn(2, $lob, PDO::PARAM_LOB);
# fetch
$stmt->fetch(PDO::FETCH_BOUND);
}
// . . .
}