inc/database.inc.php
author rejo
Mon, 04 Jun 2007 18:43:11 +0000
changeset 13 2ff220cfde13
parent 8 47dd15d8bb8c
child 47 ae140472d97c
permissions -rwxr-xr-x
[feladat @ 60] Merged 1.4.0 changes r23:59 into trunk.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
     3
require_once("MDB2.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
function dbError($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
        // General function for printing critical errors.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
        include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
        ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    10
	<h2><? echo _('Oops! An error occured!'); ?></h2>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    11
	<p class="error"><? echo $msg->getDebugInfo(); ?></p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    12
	<?        
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    13
	include_once("footer.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
        die();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'dbError');
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
$dsn = "$dbdsntype://$dbuser:$dbpass@$dbhost/$dbdatabase";
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    20
$db = MDB2::connect($dsn);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    22
if (MDB2::isError($db))
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
	// Error handling should be put.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
        error(MYSQL_ERROR_FATAL, $db->getMessage());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
// Do an ASSOC fetch. Gives us the ability to use ["id"] fields.
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 4
diff changeset
    29
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
/* erase info */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
$mysql_pass = $dsn = '';
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
?>