selectdb Back | Forward | Home

'Language Reference'

User Functions

Database Functions
  • showdbs

  • createdb

  • dropdb

  • renamedb

  • isLocked

  • lockdb

  • unlockdb

  • selectdb

  • db_exists


  • Data Manipulation Functions

    Table Functions

    Error Handling Functions

    << Last Section ( unlockdb ) selectdb Next Section ( db_exists ) >>
    Usage void selectdb ( $database )
    Purpose To select a database, so there is no need to specify one in queries
    Availability txtSQL >= 2.2.0 Beta

    This function will return TRUE if $database was successfully selected and FALSE otherwise. The useful part of this function is the fact that if a database is 'selected' using selectdb(), then in queries such as select(), there is no need to specify a database.

    Note- This function will return FALSE if the database doesn't exist

    Example 14: selectdb() Copy to Clipboard
    <?php
    if ( !$sql->selectdb('testDB') )
    {
        print
    'testDB could not be selected, txtSQL said: '.$sql->get_last_error();
    }


    $data = $sql->select(array(
        
    'table' => 'testTable', // Notice that there is no database identifier here
        
    'where' => array('strtolower(somecolumn) = value')
        ));
    ?>

    User-Contributed Comments for:
    selectdb()
    No comments found;