Home    Back    Forward    Refresh    txtSQL Homepage

createdb
Purpose: To create a new txtSQL database inside the current working directory
txtSQL >= 2.0.0 Beta
void createdb ( array( 'db' => $db ) )

This function will create a new database inside of the current working directory, as long as it does not already exists.

Note- This function will return false if the database already exists
Caveat- In windows, filenames are not case-sensative, so 'DBNAME' is the same as 'dbname', which is why it will issue an error if you try to create a database 'test', when 'TEST' exists.


Example 8: createdb() Copy to clipboard
<?php
// txtSQL created a new database named testDatabase
$sql->createdb(array('db' => 'testDatabase')) or die('Error creating txtSQL DB, txtSQL said: '.$sql->get_last_error());
?>


User Comments - createdb
Izzet <pembeci at spamsucks dot cs dot jhu dot edu>
February 28, 2005, 7:12 pm
Of course, this is only an issue if you are not the root like me.
Izzet <pembeci at cs dot jhu dot edu>
February 28, 2005, 7:12 pm
Databases are created with a 755 permission. In order to create tables (files) in them from a web page you have to change the permission to 777. For some servers if you create them via web the owner will be nobody and you will not be able to change permissions. So create them by running the script from command line first, the owner will be you and then you can set the 777 permission.

At least this was the story for me.
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 | 6 SQL Queries ]