Skip to content
Yo-An Lin edited this page Jun 17, 2016 · 3 revisions

Every ORM implements a table parser on their own, and generalize the API to support different SQL database, but I think this kind of stuff should be re-usable. If you're interested in this, the below part are the API tutorial for you to work on:

First you need to define the use statement to use the table parser:

use LazyRecord\TableParser\TableParser;

Then the second step is to create a parser object.

$parser = TableParser::create( $this->driver, $this->connection );

Where the first parameter is the SQLBuilder\Driver, which defines the SQL generator behaviours. And the second parameter is the PDO connection object. you may just pass the PDO the the factory function.

To get the table names, you may call:

$tables = $parser->getTables();

To parse the table schema, you may call getTableSchemaMap method, which retunrs the Schema object:

foreach ($tables as $table) {
    $schema = $parser->getTableSchemaMap( $table );
}

Clone this wiki locally