473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

55
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?
Feb 28 '16 #1

✓ answered by Dormilich

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.

2 1329
Dormilich
8,658 Expert Mod 8TB
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.
Feb 29 '16 #2
RonB
589 Expert Mod 512MB
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.
Feb 29 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Joshua Beall | last post by:
Hi All, I am working on a registration system, and one of the things I am going to need to be able to do it setup the database tables for each event that I have registration for. Normally I...
2
by: Thomas Bartkus | last post by:
Is it safe to say that restoring the directory from a backup would that restore all database data and structure? All usr/pwd and GRANT info? Thomas Bartkus
0
by: R. Tarazi | last post by:
Hello, We are planning to reprogramm our search machine and website. Since we have call agents who query the same database as the customers do, we had the idea of splitting the database to 2...
0
by: SQLServer007 | last post by:
25 more days until the "get it free" promotion runs out for xSQL Object (you can get it from http://www.x-sql.com) Here are just some of the great features packed in the product: - Compare SQL...
2
by: Raffi | last post by:
I use the --all-databases switch to backup my entire database. Sometimes there's a need to restore individual databases or tables form the backup file. What command should I use for this? ...
1
by: vineyard_saker | last post by:
Hi, I am new to MySql and I want to practice querying by playing around a relatively large and complex database without having to enter all the data myself. Is there a publicly available MySql...
9
by: noor.rahman | last post by:
I was wondering how it may be possible to query 2 MySQL databases using one query statement from PHP. For instance: SELECT database1.tableA.field1 UNION database2.tableB.field2. My concern...
4
by: Tracey | last post by:
I have a Mysql database hosted on a remote server. Previously, I could always connect to those databases using the 3.51 ODBC connector and linking the tables in Access. The benefit of this is that...
1
by: penny111 | last post by:
Hi there, I've migrated a database named "crime" from an MS Access database to MySQL 5.0.37 using the MySQL Migration Toolkit 1.1.11. What i want to do is to copy the database folder from ...
2
by: sandeep jahagir | last post by:
HI, I want to merge TESTLINK and BUGZILLA databases into one, even though they have mysql DB but i have installed in different ports(TESTLINK-3306 and BUGZILLA-3307). so with respect to TEST...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.