It is bad practice to save binary data in the database, mostly when this data are intend to be processed by a file server, such as pictures or your DOCX.
Anyway, since OpenTBS 1.8.1, you can open an DOCX (or any Ms Office, LibreOffie or zip archive) from a PHP file handle.
You can use this feature to easily merge your template from the database :
// retrieve binary data of the file
$rs = mysql_query($dbc, "SELECT data FROM files WHERE id=$id");
$rec= mysql_fetch_array($rs, MYSQLI_ASSOC);
mysql_free($rs);
// create a temporary file
$temp = tmpfile();
fwrite($temp, $rec['file']);
unset($rec); // free PHP memory
// Open the file with OpenTBS
$TBS = new clsTinyButStrong;
$TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
$TBS->LoadTemplate($temp);
...