Giter Site home page Giter Site logo

php-sql-parser's People

Watchers

 avatar

php-sql-parser's Issues

Parser fails when it finds a newline after SELECT statement

If I try :

$parser = new PHPSQLParser('SELECT
name, 1, test;');

PHP is giving me error (see method process_select_expr):
- Warning: E_WARNING array_pop() expects parameter 1 to be array, string given
- Fatal error: Cannot use string offset as an array 

A newline after between SELECT and field list makes the parser to fail.

Original issue reported on code.google.com by [email protected] on 14 Dec 2010 at 4:06

if(count($processed) == 1)

if(count($processed) == 1) {
  ...
}

produces errors on some sql-statments.
i added:

if(is_array($processed)) {
  if(count($processed) == 1) {
    ...
  }
}

Original issue reported on code.google.com by [email protected] on 2 Mar 2011 at 1:28

NOW() function makes parsing to fail

SELECT NOW();

or 

SELECT test1
FROM table1
WHERE test_date < NOW();

I get a blank page showing this error :

Fatal error: Cannot use string offset as an array in 
H:\Project\Openflyers30\classes\PHPSQLParser.php on line 1145

For any SQL queries where I've "NOW()", the parser always fails.

Original issue reported on code.google.com by [email protected] on 5 Jan 2011 at 9:40

<> in split_sql() wont split

What steps will reproduce the problem?
select * from test where value<>"brainstorm"

Suggestion
i removed the "|([^ ,]+)" from the preg_split(),
fixed this problem for me, but don't know if it is breaking somthing.

What is the expected output?
    [WHERE] => Array
        (
            [0] => Array
                (
                    [expr_type] => colref
                    [base_expr] => value
                    [sub_tree] => 
                )

            [1] => Array
                (
                    [expr_type] => operator
                    [base_expr] => <>
                    [sub_tree] => 
                )

            [2] => Array
                (
                    [expr_type] => const
                    [base_expr] => "brainstorm"
                    [sub_tree] => 
                )

        )

What do you see instead?
    [WHERE] => Array
        (
            [0] => Array
                (
                    [expr_type] => colref
                    [base_expr] => value
                    [sub_tree] => 
                )

            [1] => Array
                (
                    [expr_type] => colref
                    [base_expr] => <>"brainstorm"
                    [sub_tree] => 
                )

        )

Original issue reported on code.google.com by [email protected] on 2 Mar 2011 at 1:20

Select parser problem with quote

What steps will reproduce the problem?
1. use the parser to parse a query like Select table.`field` from table 
2.
3.

What is the expected output? What do you see instead?
 if you look at the 'Select' statement generated you will get

Array
(
    [0] => Array
        (
            [expr_type] => colref
            [alias] => `prj_seq_key`
            [base_expr] => aje.
            [sub_tree] => 
        )
)

where you sould get

Array
(
    [0] => Array
        (
            [expr_type] => colref
            [alias] => aje.`prj_seq_key`
            [base_expr] => aje.prj_seq_key`
            [sub_tree] => 
        )


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 13 Jan 2011 at 12:40

Undefined offset error

What steps will reproduce the problem?
1. Try an parse the following query:
2. UPDATE table1 SET field1='foo' WHERE field2='bar' AND id=(SELECT if FROM 
test1 t where t.field1=(SELECT id from test2 t2 where t2.field = 'foo'))                            

Granted, its my own typo ("if" should be "id" in the first subselect) but I 
dont think php-sql-parser should be throwing an undefined offset exception.

What is the expected output? What do you see instead?
Expected: Blank screen.
See instead: Notice: Undefined offset: 1 in /var/www/php-sql-parser.php on line 
1102

Can be fixed by changing line 1102 of php-sql-parser.php from:
 $sub_expr = $tokens[$key+1];
to:
 if(!empty($tokens[$key+1])) $sub_expr = $tokens[$key+1];


Original issue reported on code.google.com by [email protected] on 2 Jan 2011 at 2:50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.