Home    Back    Forward    Refresh    txtSQL Homepage

selectdb
Purpose: To select a database, so there is no need to specify one in queries
txtSQL >= 2.2.0 Beta
void selectdb ( $database )

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 Comments - selectdb
No comments posted yet;
Last Page Next Page

'Language Reference'

User Functions

Database Functions
  • showdbs
  • createdb
  • dropdb
  • renamedb
  • isLocked
  • lockdb
  • unlockdb
  • selectdb
  • db_exists

    Data Manipulation Functions

    Table Functions

    Error Handling Functions

    SQL Syntax

  • [ txtSQL Documentation powered by txtSQL | 5 SQL Queries ]