Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on parsing encoded sql field #4

Open
manuelddahmen opened this issue Feb 26, 2022 · 0 comments
Open

Error on parsing encoded sql field #4

manuelddahmen opened this issue Feb 26, 2022 · 0 comments

Comments

@manuelddahmen
Copy link

I have a FatalError in parsing SQL:

SELECT sql FROM sqlite_schema WHERE type ='table' AND tbl_name='table_hospitalises';
Fatal error: Uncaught Exception: Expect '(': ' ( chambre integer def...' FROM 'CREATE TABLE table_hospitalises ( chambre integer default 300 primary key , nom varchar(30) default '', prenom varchar(30) default '' , sex varchar(1) default 'M')' in C:\Users\manue\PhpstormProjects\untitled\vendor\maghead\sqlite-parser\src\BaseParser.php:70 Stack trace: #0 C:\Users\manue\PhpstormProjects\untitled\vendor\maghead\sqlite-parser\src\CreateTableParser.php(72): Maghead\SqliteParser\BaseParser->expect() #1 C:\Users\manue\PhpstormProjects\untitled\src\agenda.php(30): Maghead\SqliteParser\CreateTableParser->parse() #2 C:\Users\manue\PhpstormProjects\untitled\src\agenda.php(63): findInfoTable() #3 {main} thrown in C:\Users\manue\PhpstormProjects\untitled\vendor\maghead\sqlite-parser\src\BaseParser.php on line 70

My code:

    global $db;
    $createTableParser = new CreateTableParser();

    $sql = "SELECT sql FROM sqlite_schema WHERE type ='table' AND tbl_name='".$tablename."';";
    echo $sql;
    $parser = new CreateTableParser;
    $stmt = $db->prepare($sql);
    $stmt->execute();
    if($stmt!==false) {

        $results = $stmt->fetchAll(PDO::FETCH_BOTH);
        if($results!==false) {
            $table = $parser->parse($results[0]['sql']);
        } else {
             echo "DEBUG No Lines 1";
        }
    }
    else echo "DEBUG No Lines 2";

    var_dump($table);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant