Holger Holger - 1 year ago 76
PHP Question

propel sql:insert throws error 'Unable to parse contents of sqldb.map'

I'm trying to build a project with Propel these days. I did the basic 'bookstore' tutorial on propelorm.org/documentation/02-buildtime.html, but when I'm trying to finally insert the generated sql code via propel, to fill the database, the following error is thrown:

[Exception] Unable to parse contents of "/sqldb.map".

Unfortunately I've got no idea what went wrong; I followed the tutorial as precisely as possible.

Information about my installation and what I've done so far:

1) Localhost installation (Mac OS 10.8.5) with PHP 5.4.27 (DOM Module, PDO and SPL enabled) and MySQL 5.6.19.

2) successfully parsed Composer.json with:

"require": {
"propel/propel": "~2.0@dev"
"autoload": {
"classmap": ["bookstoreDb/generated-classes/"]

3) created a schema.xml with foreign keys, exactly like in the tutorial (propelorm.org/documentation/02-buildtime.html).

4) created a config file, propel.yaml, in subfolder 'conf', again like in the tutorial.

5) used the propel scripts to generate the necessary sql (
propel sql:build
), model (
propel model:build
) and configuration files (
propel config:convert
). The result of these commands are as indicated as in the tutorial.

6) created the database 'bookstore' successfully via terminal.

7) trying to insert the sql code via
propel sql:insert
. Now the error as described above is thrown:

[Exception] Unable to parse contents of "/sqldb.map".

Here is the index.php of the project:

// setup the autoloading
require_once 'vendor/autoload.php';
// setup Propel
require_once 'bookstoreDb/generated-conf/config.php';

// Here I get the parse error: parse error in ../bookstore/bookstoreDb/generated-classes/Base/Author.php on line 138
$author = new Author();

And here the config.php:

$serviceContainer = \Propel\Runtime\Propel::getServiceContainer();
$serviceContainer->setAdapterClass('bookstore', 'mysql');
$manager = new \Propel\Runtime\Connection\ConnectionManagerSingle();
$manager->setConfiguration(array (
'classname' => 'Propel\\Runtime\\Connection\\ConnectionWrapper',
'dsn' => 'mysql:host=localhost;dbname=bookstore',
'user' => 'root',
'password' => 'password',
'attributes' =>
array (
$serviceContainer->setConnectionManager('bookstore', $manager);

Where may be the problem? And is there some other way to setup a basic project? I'd appreciate every help! Thanks!

Answer Source

I submitted an issue for this: https://github.com/propelorm/Propel2/issues/694

SqlBuildCommand uses configured sql-dir 

SqlInsertCommand only uses the command line option 

adding --sql-dir option with correct sql dir to propel sql:insert does work

fix is submitted https://github.com/propelorm/Propel2/pull/695 but not merged yet

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download