irm-1.6-b3/lib/Databases.php
/** List of uninitialised databases.
     * Similar in concept to Databases::List(), but instead does a
     * check on each configured database to see if it looks like a
     * configured IRM database, and if so, does not put it in the list.
     */
List of uninitialised databases.
Similar in concept to Databases::List(), but instead does a
check on each configured database to see if it looks like a
configured IRM database, and if so, does not put it in the list.
List of uninitialised databases . Similar in concept to Databases :: List () but instead does a check on each configured database to see if it looks like a configured IRM database and if so does not put it in the list .
function Uninitialised()
    {
        $dflsocket = ini_get('mysql.default_socket');
        $rv = array();
        $data = Config::ReadConfig('database');
        foreach ($data as $id => $vals)
        {
            if (!is_array($vals))
            {
                echo '<p id="warning">'
                    ._("Section value list is not an array -- I think your config file is malformed")
                    ."</p>\n";
                break;
            }
            $DSN = @$vals['DSN'];
            $socket = @$vals['socket'];
            if (!$DSN)
            {
                echo "<p>".sprintf(
                        _("No DSN for database %s (%s)"),
                        @$vals['name'], $id)
                    ."</p>\n";
                continue;
            }
            $dbh = new IRMDB($DSN, $socket);
            if ($dbh->error)
            {
                $dberror = sprintf(_('<p id="warning">Could not connect to database %s (%s): %s</p>'),
                    @$vals['name'], $id,
                    $dbh->error->getMessage()
                );
                unset($dbh);
                continue;
            }
            $dbh->pushErrorHandling(PEAR_ERROR_RETURN);
            $err = $dbh->query("SELECT * FROM computers WHERE ID=0");
            if (MDB::isError($err))
            {
                $name = @$vals['name'];
                if (!$name)
                {
                    $name = _("Unknown database");
                }
                $rv[$id] = $name;
            }
            $dbh->disconnect();
            unset($dbh);
        }
        ini_set('mysql.default_socket', $dflsocket);
        return $rv;
    }
function Uninitialised ( ) { $ dflsocket = ini_get ( 'mysql.default_socket' ) ; $ rv = array ( ) ; $ data = Config :: ReadConfig ( 'database' ) ; foreach ( $ data as $ id => $ vals ) { if ( ! is_array ( $ vals ) ) { echo '<p id="warning">' . _ ( " Section value list is not an array -- I think your config file is malformed " ) . " </p> \n " ; break ; } $ DSN = @ $ vals [ 'DSN' ] ; $ socket = @ $ vals [ 'socket' ] ; if ( ! $ DSN ) { echo " <p> " . sprintf ( _ ( " No DSN for database %s (%s) " ) , @ $ vals [ 'name' ] , $ id ) . " </p> \n " ; continue ; } $ dbh = new IRMDB ( $ DSN , $ socket ) ; if ( $ dbh -> error ) { $ dberror = sprintf ( _ ( '<p id="warning">Could not connect to database %s (%s): %s</p>' ) , @ $ vals [ 'name' ] , $ id , $ dbh -> error -> getMessage ( ) ) ; unset ( $ dbh ) ; continue ; } $ dbh -> pushErrorHandling ( PEAR_ERROR_RETURN ) ; $ err = $ dbh -> query ( " SELECT * FROM computers WHERE ID=0 " ) ; if ( MDB :: isError ( $ err ) ) { $ name = @ $ vals [ 'name' ] ; if ( ! $ name ) { $ name = _ ( " Unknown database " ) ; } $ rv [ $ id ] = $ name ; } $ dbh -> disconnect ( ) ; unset ( $ dbh ) ; } ini_set ( 'mysql.default_socket' , $ dflsocket ) ; return $ rv ; }
List of uninitialised databases.
List of uninitialised databases .
///* //{{{ // Bollocks query just to try and trigger an error if // there's no table.  Can't use a query that isn't // guaranteed to work on any version of IRM.