Trying to follow the tutorial for zf1: about the database connection

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Trying to follow the tutorial for zf1: about the database connection

Javier Garcia
Hi,

I'm following this tutorial:
http://framework.zend.com/manual/1.12/en/learning.quickstart.create-model.html

When I run |php scripts/load.mysql.php| it says:

    SQLSTATE[42000] [1102] Incorrect database name
    '/home/tirengarfio/workspace/ZendFW/gaziende/application/../data/db/guestbook-dev.db'

So I just tried to change the line

|resources.db.params.dbname=  APPLICATION_PATH"/../data/db/guestbook-dev.db"|

to

|resources.db.params.dbname=  "guestbook-dev"  and  created anew  database called guestbook.|

but I get another error about the "guestbook" is not a file, exactly:

    PHP Warning:
    file_get_contents(/home/tirengarfio/workspace/ZendFW/gaziende/scripts/data.mysql.sql):
    failed to open stream: No such file or directory in
    /home/tirengarfio/workspace/ZendFW/gaziende/scripts/load.mysql.php
    on line 81

This is the code around the line 81 error (checkout what var_dump()
returns):

|// Check to see if we have a database file already
$options=  $bootstrap->getOption('resources');
$dbFile=  $options['db']['params']['dbname'];
if  (file_exists($dbFile))  {
     unlink($dbFile);
}

// this block executes the actual statements that were loaded from
// the schema file.
try  {
     $schemaSql=  file_get_contents(dirname(__FILE__)  .  '/schema.mysql.sql');
     // use the connection directly to load sql in batches
     $dbAdapter->getConnection()->exec($schemaSql);
     var_dump($dbFile);die();  // this returns "guestbook-dev"
     chmod($dbFile,  0666);|

So.. how should I set the name for the database connection exactly?

Note: the example of the tutorial is for Sqlite and I'm trying to use
MySQL. Is that point? I never used Sqlite.

Javi