SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Install.php

  1. #1
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Install.php

    I have noticed with a few database scripts there is an install.php file which installs the database without the user having to telnet and inport the database.

    Is there is special way to do this for this?

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    those are very simple. they just run mysql_query()'s for the "CREATE DATABASE..." and "CREATE TABLE..." queries -- just as you would via telnet. open up an install.php and take a look. that's the easiest way to see how something's done.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    SitePoint Zealot theFinn's Avatar
    Join Date
    Oct 2000
    Location
    Edmonton
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Larry got it

    The latest install.php for phpBB v2.0 acutally loads the SQL from some schema files we have and creates the tables based on that. I would recommend this method if you are developing a script that would work different database servers, it'll save you alot of work inside the script.
    - theFinn
    Creator and Project Manager, phpBB
    http://www.theFinn.net
    http://www.tarotclass.com

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How come no more beta versions available?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do note that 99% of hosts won't allow CREATE DATABASE permissions, so the user will have to have one already made, which the host will usually provide or have a utility that will allow the user to create one.

    freddy, you talking about phpBB2?

    You can always get the latest CVS if you have program for it.

    See this thread for the CVS lowdown: http://phpbb.sourceforge.net/phpBB2/...pic.php?t=1055
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  6. #6
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys, I'm thinking just leaving it so they can inport the database structure.

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'd still make the script so it will create all the necessary tables. just not the database itself.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the cvs link, I will grab a copy soon. As for hosts who who don't give you create database privs, Shared hosting sucks.... If you are serious about running an online business, look at dedicated solutions.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Defender1
    i'd still make the script so it will create all the necessary tables. just not the database itself.
    Defender1, any idea how that is done?

  10. #10
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sql "CREATE TABLE users (id INT(5) NOT NULL AUTO_INCREMENT, username VARCHAR(32) NOT NULL, email VARCHAR(32) , PRIMARY KEY (id), UNIQUE (id))"
    That will create a table called users
    the primary key is id, and it is also flagged as unique, so it cna't be duplicated, as well as it's not null (can't be empty)
    id is also auto-incremented with every row that's inserted.
    you can insert the first id, and it will start it's counting from there

    username is a varchar, can't be null.

    email is a varchar as well, it can be null.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  11. #11
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Defender1
    the primary key is id, and it is also flagged as unique, so it cna't be duplicated
    no need to make it UNIQUE -- a PRIMARY KEY is already unique.

  12. #12
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea, good point.
    but it is a good example of how to make another field unique if he needs to
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •