Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // load the TinyButStrong libraries
- if (version_compare(PHP_VERSION,'5')<0) {
- include_once('tbs_class_php4.php'); // TinyButStrong template engine for PHP 4
- } else {
- include_once('tbs_class_php5.php'); // TinyButStrong template engine
- }
- // load the OpenTBS plugin
- if (file_exists('tbs_plugin_opentbs.php')) {
- include_once('tbs_plugin_opentbs.php');
- } else {
- include_once('../tbs_plugin_opentbs.php');
- }
- $TBS = new clsTinyButStrong; // new instance of TBS
- $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load OpenTBS plugin
- //work with oracle
- $conn = oci_connect('hr', 'welcome', 'localhost/XE');
- if (!$conn) {
- $e = oci_error();
- trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
- }
- $stid = oci_parse($conn, 'SELECT department_name FROM departments');
- oci_execute($stid);
- while (($data = oci_fetch_array($stid, OCI_BOTH))) {
- // Use the uppercase column names for the associative array indices
- // echo $row[0] . " and " . $row['DEPARTMENT_ID'] . " are the same<br>\n";
- // echo $row[1] . " and " . $row['DEPARTMENT_NAME'] . " are the same<br>\n";
- var_dump($data);
- }
- oci_free_statement($stid);
- oci_close($conn);
- // Load the template
- $TBS->LoadTemplate('example.docx', OPENTBS_ALREADY_UTF8);
- // Merge data
- $TBS->MergeBlock('a,b', $data);
- // Define the name of the output file
- $file_name = str_replace('.','_'.date('Y-m-d').'.',$template);
- // Output as a download file (some automatic fields are merged here)
- if ($debug==3) { // debug mode 3
- $TBS->Plugin(OPENTBS_DEBUG_XML_SHOW);
- } elseif ($suffix==='') {
- // download
- $TBS->Show(OPENTBS_DOWNLOAD, $file_name);
- } else {
- // save as file
- $file_name = "example.docx";
- $TBS->Show(OPENTBS_FILE+TBS_EXIT, $file_name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement