MySQL: How do i know what table and database my php code is work with?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neogazz
    New Member
    • Apr 2010
    • 55

    MySQL: How do i know what table and database my php code is work with?

    I know the PHP command "CREATE DATABASE DataBaseName" creates a database in MySQL. I also know that the command "CREATE TABLE TableName" creates a table. But how is the CREATE TABLE command linked to the DATABASE in MySQL, I mean what if there are multiple databases, then in which database would the table be created, how is the table linked to the database?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I know the PHP command "CREATE DATABASE DataBaseName" creates a database in MySQL.
    that’s not a PHP command, that’s an SQL command. PHP only sends that to the database, nothing more.

    I mean what if there are multiple databases, then in which database would the table be created
    the currently active database. in mysqli you can explicitly switch between databases. for PDO you’d probably have to create a new connection, but I never had the need to create databases in PHP.

    Comment

    • RonB
      Recognized Expert Contributor
      • Jun 2009
      • 589

      #3
      It's vary rare and IMO silly to use your own custom php script to create the database. Normally you would use a tool specifically designed for this purpose. The most common one talked about in forums like this is phpMyAdmin which is a 3rd party php app for the administration of mysql. I on the other hand prefer to use Mysql Workbench.

      Comment

      Working...