As a fledgling php coder, Q suggested these methods for exploring some confusing php objects. 

I knew that $result was the output from a symfony plugin.  I just did not know what all was contained within this object.

$result is actually the obj/variable in question.

Anyway, here are the two options…

echo nl2br(print_r($result, true));
var_dump($result);

,

This will only work with SQL 2005 and prior.  SQL 2008 does not work.  Symfony commands are 1.0 style and other versions of symfony will need to use the updated command structure.

SQL:

1. Create a database within SQL 2005 (example: testdb)
2. Authenticate the db with SQL Server Authentication (sa)

Windows Symfony Install:

1.Within the main php directory replace ntwdblib.dll with version 2000.80.194.0.  Google search for version or obtain from one of the links within php mssql_connect documentation.
2. Stop and restart apache
3. Clear cache in symfony.  If you receive pake errors with inverted slashes during “symfony cc”, then edit your spPakeMisc.php file and retry cache clear.
4. Edit your databases.yml with the following information.  Replace the password, ip address (or localhost), and database name with your information.  Remember that yml files must have spaces, not tabs.

all:
  propel:
    class:          sfPropelDatabase
    param:
       dsn:            mssql://sa:password@10.1.1.1/testdb

5. Paste your dsn line above into the propel.database.url section of propel.ini. Paste the dsn line minus the database name into the propel.database.createUrl section.
6. Clear cache in symfony.
7. Be sure your schema.yml is correct.
8. From your project directory do symfony propel-build-model and be sure there are no errors.
9. From your project directory do symfony propel-build-sql
10. Although it is unlikely to work, you can try to do a symfony propel-insert-sql
11. If it inserts correctly, then you are set.  Most likely you will notice that all the SQL statements did not execute successfully.  You will probably see Native Errors regarding “Incorrect syntax near \’_PK\’.]” along with other errors.  This is fixed in propel 1.3 if you want to try to figure out how to upgrade symfony or install an updated propel plugin.  Otherwise, you are going to want to manually correct your propel generated sql based on the recommendations in this thread.  If your project is myproject, then your generated sql lives here:  c:\myproject\data\sql\lib.model.schema.sql

I’ll quote the important global search and replace information here:

(Ignore the quotes  )
seek for: “]_PK”
replace with: “_PK]”

Then you will also need to alter all the strings:

seek for: “ON UPDATE RESTRICT ON DELETE RESTRICT”
replace for: “ON UPDATE NO ACTION ON DELETE NO ACTION”

In addition you will need to also move all the entries (their block of statements: BEGIN AND END included) that carry:
” ON UPDATE NO ACTION ON DELETE NO ACTION”
to the end of the script

and finally move also all the
” ADD CONSTRAINT “
entries (their block of statements: BEGIN AND END included) to the bottom of the file

12. Copy this file to somewhere on your sql server.  Double-click to open it within SQL server and “execute” to populate the sql into your database.
13. Generate frontend and backend applications within symfony.  Generation of an propel-init-admin in the backend is a quick way to test database read/write.

Notes:
Be sure that the correct version of the dll file is running.  Restarting apache should be enough, but you know how windows dll files are.  If something doesn’t seem to be working correctly, clear the symfony cache.  You know how the symfony cache can bugger up things.

Good luck.

, , , , ,

September 24th, 2005

Lesson in using arrays in PHP.