Regular Exressions and PHP

Discussion in 'PHP' started by merianos, Jun 28, 2008.

  1. #1
    Hello . . .

    I like to create a regular exression that muches all the queries from an sql file.

    my patern is ^#|.+|;& that means Starting with a query comments it has any character until find the question mark that stands for the end of the query.

    Is that corect ? ? ?

    In into my MySQL file i have comments for each mysql query and then comes the mysql query.

    the sql file is in the following form

    #
    # dbtables.sql
    #
    # Simplifies the task of creating all the database tables
    # used by the login system.
    #
    # Can be run from command prompt by typing:
    #
    # mysql -u yourusername -D yourdatabasename < dbtables.sql
    #
    # That's with dbtables.sql in the mysql bin directory, but
    # you can just include the path to dbtables.sql and that's
    # fine too.
    #
    # Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
    # Last Updated: August 13, 2004
    #

    #
    # Table structure for users table
    #
    DROP TABLE IF EXISTS users;

    CREATE TABLE users (
    username varchar(30) primary key,
    password varchar(32),
    userid varchar(32),
    userlevel tinyint(1) unsigned not null,
    email varchar(50),
    timestamp int(11) unsigned not null
    );


    #
    # Table structure for active users table
    #
    DROP TABLE IF EXISTS active_users;

    CREATE TABLE active_users (
    username varchar(30) primary key,
    timestamp int(11) unsigned not null
    );
     
    merianos, Jun 28, 2008 IP
  2. merianos

    merianos Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just i want to extract any SQL Query to an array . . .

    Is there any way to hapen that by using Regular Exprissions ? ? ?
     
    merianos, Jun 30, 2008 IP