/** * Create tables and indexes for the given database type. * * @throws PhpError * @access public */ function createTables() { MDB::loadFile('Manager'); $manager =& new MDB_Manager(); $err = $manager->connect($this->dbConn); if (MDB::isError($err)) { return $err; } $filename = dirname(__FILE__) . '/database_schema.xml'; $err = $manager->updateDatabase($filename, $filename . '.old', array('database' => $this->dbConn->database_name)); if (MDB::isError($err)) { return $err; } $dsn = $this->dbConn->getDSN(); if (isset($dsn['phptype']) && $dsn['phptype'] == 'mysql') { $this->dbConn->query('CREATE INDEX s_mod_idx ON statements (modelID)'); $sql = 'CREATE INDEX s_sub_pred_idx ON statements (subject(200),predicate(200))'; $this->dbConn->query($sql); $this->dbConn->query('CREATE INDEX s_obj_idx ON statements (object(250))'); } return true; }
<?php # $Id$ require_once "grab_globals.inc.php"; include "config.inc.php"; include "functions.inc"; require_once "database.inc.php"; MDB::loadFile("Date"); include "{$dbsys}.inc"; function date_time_string($t) { global $twentyfourhour_format; if ($twentyfourhour_format) { $timeformat = "%H:%M:%S"; } else { # This bit's necessary, because it seems %p in strftime format # strings doesn't work $ampm = utf8_date("a", $t); $timeformat = "%I:%M:%S{$ampm}"; } return utf8_strftime("%A %d %B %Y " . $timeformat, $t); } # Convert a start time and end time to a plain language description. # This is similar but different from the way it is done in view_entry. function describe_span($starts, $ends) { global $twentyfourhour_format; $start_date = utf8_strftime('%A %d %B %Y', $starts); if ($twentyfourhour_format) { $timeformat = "%H:%M:%S"; } else {
// Set $db_create to 0 to NOT create the database. $db_create = 1; // Communication protocol tu use. For pgsql, you can use 'unix' instead of // 'tcp' to use Unix Domain Sockets instead of TCP/IP. $db_protocol = "tcp"; /************************** * DBMS specific options ***************************/ //****ORACLE***** // Home directory path where Oracle is installed if it is running in the local machine. // Default value: value of the environment variable ORACLE_HOME $oci8_home = ""; /************************** * End of database settings ***************************/ include_once "MDB.php"; MDB::loadFile("Manager"); $schema_file = "mrbs.schema.xml"; $variables = array("database_name" => $db_database, "database_create" => $db_create); $dsn = array("phptype" => $dbsys, "username" => $db_login, "password" => $db_password, "hostspec" => $db_host, "protocol" => $db_protocol, "port" => $db_port); $options = array("HOME" => $oci8_home, "optimize" => 'portability'); $manager = new MDB_manager(); $manager->connect($dsn, $options); $success = $manager->updateDatabase($schema_file, $schema_file . ".before", $variables); if (MDB::isError($success)) { echo "Error: " . $success->getMessage() . "<BR>"; echo "Error: " . $success->getUserInfo() . "<BR>"; } if (count($manager->warnings) > 0) { echo "WARNING:<BR>", implode($manager->getWarnings(), "!\n"), "\n"; }
// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA /** * MDB container for Authentication * * @package LiveUser * @category authentication */ /** * Require parent class definition and PEAR::MDB class. */ require_once 'LiveUser/Auth/Common.php'; require_once 'MDB.php'; MDB::loadFile('Date'); /** * Class LiveUser_Auth_Container_MDB * * Description: * This is a PEAR::MDB backend driver for the LiveUser class. * A PEAR::MDB connection object can be passed to the constructor to reuse an * existing connection. Alternatively, a DSN can be passed to open a new one. * * Requirements: * - File "LoginManager.php" (contains the parent class "LiveUser") * - Array of connection options or a PEAR::MDB connection object must be * passed to the constructor. * Example: array('dsn' => 'mysql://*****:*****@host/db_name', * 'connection => &$conn, # PEAR::MDB connection object * 'loginTimeout' => 0,
// // MDB test script. // // BC hack to define PATH_SEPARATOR for version of PHP prior 4.3 if (!defined('PATH_SEPARATOR')) { if (defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") { define('PATH_SEPARATOR', ';'); } else { define('PATH_SEPARATOR', ':'); } } ini_set('include_path', '..' . PATH_SEPARATOR . ini_get('include_path')); // MDB.php doesnt have to be included since manager.php does that // manager.php is only necessary for handling xml schema files require_once 'MDB.php'; MDB::loadFile('Manager'); // only including this to output result data require_once 'Var_Dump.php'; PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error'); function handle_pear_error($error_obj) { print '<pre><b>PEAR-Error</b><br />'; echo $error_obj->getMessage() . ': ' . $error_obj->getUserinfo(); print '</pre>'; } // just for kicks you can mess up this part to see some pear error handling $user = '******'; $pass = '******'; //$pass = ''; $host = 'localhost'; $db_name = 'metapear_test_db';
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS| // | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY| // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | // | POSSIBILITY OF SUCH DAMAGE. | // +----------------------------------------------------------------------+ // | Author: Manuel Lemos <*****@*****.**> | // +----------------------------------------------------------------------+ // // $Id: setup_test.php,v 1.10.4.1 2004/01/08 13:43:00 lsmith Exp $ // require 'MDB.php'; MDB::loadFile('Manager'); MDB::loadFile('metabase_wrapper'); /** * Part of Metabase test suite * * @package MDB * @category Database * @author Manuel Lemos <*****@*****.**>> */ function Output($message) { echo $message, "\n"; } function Dump($output) { echo $output; }
// $Id: MDB_pear_wrapper_test.php,v 1.21 2003/01/18 21:35:19 lsmith Exp $ // // MDB test script for the PEAR DB Wrapper. // // BC hack to define PATH_SEPARATOR for version of PHP prior 4.3 if (!defined('PATH_SEPARATOR')) { if (defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") { define('PATH_SEPARATOR', ';'); } else { define('PATH_SEPARATOR', ':'); } } ini_set('include_path', '..' . PATH_SEPARATOR . ini_get('include_path')); require_once 'MDB.php'; MDB::loadFile('peardb_wrapper'); require_once 'Var_Dump.php'; // just for kicks you can mess up this part to see some pear error handling $user = '******'; $pass = '******'; //$pass = ''; $host = 'localhost'; $db_name = 'metapear_test_db'; // Data Source Name: This is the universal connection string $dsn = "mysql://{$user}:{$pass}@{$host}/{$db_name}"; // MDB::connect will return a Pear DB object on success // or a Pear DB Error object on error // You can also set to TRUE the second param // if you want a persistent connection: // $db = DB::connect($dsn, TRUE); $db =& DB::connect($dsn);