; -- -- Create a new virtual path in Virtuoso -- -- Point to $VIRTUOSO/vsp/testapp on filesystem -- db.dba.vhost_remove (lpath=>'/myapp'); db.dba.vhost_define ( lpath=>'/myapp', ppath=>'/testapp', is_dav=>0, is_brws=>0, vsp_user=>'MYADMIN', def_page=>'myapp.php') ; -- -- End of sample -- And the $VIRTUOSO/vsp/testapp/myapp.php: <?php $db = odbc_connect(__virt_internal_dsn(), null, null); if (!$db) { error_log('odbc_connect failed'); } $rs = odbc_exec($db, 'select * from MYAPP.DBA.MYTEST'); odbc_result_all($rs); odbc_close($db);
/** * Returns the current connection resource. * The resource is created lazily if it doesn't exist. * @retun resource */ public function connection() { if (!$this->_connection) { $options = $this->_adapterOptions; // ini_set('odbc.default_cursortype', SQL_CURSOR_FORWARD_ONLY); // determine connection function if (isset($options['use_persistent_connection']) && (bool) $options['use_persistent_connection'] === true) { $odbcConnectFunction = 'odbc_pconnect'; } else { $odbcConnectFunction = 'odbc_connect'; } // try to connect if (function_exists('__virt_internal_dsn')) { // via Virtuoso hosting $this->_connection = $odbcConnectFunction(__virt_internal_dsn(), null, null); } else { // check for dsn parameter if (!isset($options['dsn'])) { throw new Erfurt_Store_Adapter_Exception('Your config.ini lacks a store.virtuoso.dsn parameter.'); } else { $dsn = (string) $options['dsn']; } // check for username parameter if (!isset($options['username'])) { throw new Erfurt_Store_Adapter_Exception('Your config.ini lacks a store.virtuoso.username parameter.'); } else { $username = (string) $options['username']; } // check for password parameter if (!isset($options['password'])) { throw new Erfurt_Store_Adapter_Exception('Your config.ini lacks a store.virtuoso.password parameter.'); } else { $password = (string) $options['password']; } // via php_odbc $this->_connection = @$odbcConnectFunction($dsn, $username, $password); $this->_user = $username; } // success? if (false === $this->_connection) { $error = error_get_last(); $message = 'Unable to connect to Virtuoso Universal Server via ODBC: ' . PHP_EOL . $error['message']; throw new Erfurt_Store_Adapter_Exception($message); } } return $this->_connection; }