How to create MySQL database by time in PHP

Source: Internet
Author: User
How does PHP create MySQL database by time?
This post was last edited by Universeos on 2013-03-17 11:34:14

I currently have a requirement to create a database by month (that is, date (' Ym '), my current SQL statement:

$sql = "CREATE TABLE IF not EXISTS time (file_id Int (ten) auto_increment primary key,filename varchar), filepath varchar ( ), FileSize Int (ten), Uploadtime date) ";

If the time assignment time=date (' Ym ') will be error (SQL syntax is incorrect), how to write correctly?


------Solution--------------------
$dbtime = Date (' Ym ');
$sql = "CREATE TABLE IF not EXISTS ' $dbtime ' (.... ";

In fact, you have a character in front of it is not simple and clear?
$dbtime = ' t '. Date (' Ym ');
$sql = "CREATE TABLE IF not EXISTS $dbtime (.... ";

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.