It’s easy to create transactions with Propel. This can be very useful when you are deleting rows from your database from multiple tables, and want to do an “all or nothing” approach so that things don’t get messy. More…
Web Development Articles
February 29, 2008 – 1:45pm Propel Transactions with Symfony
February 9, 2008 – 5:02pm Using svnX with svn+ssh on a non-standard port
svnX is a great mac GUI for svn repositories. A lot of our svn servers are accessed via non-standard ports for security, and a limitation of the svn+ssh syntax is that you can’t specify a non-standard port in the address name. To get around this in the command line, you can set a local environment variable “SVN_SSH” like so: More…
January 24, 2008 – 4:48pm Propel Criteria Left Join: using addJoin() and addAlias() to join a table twice
Here is a way to do left join on two columns in a table that both were foreign keys in the same table using Propel. This might happen if for example you have a table with a parent_id and a child_id in a nested set that both refer to the same table, or as an example you have a table “documentation” and each documentation can be categorized into a main category and a sub category.
What happens when you want to do a left join in your documentation query, so that if present both the related category and sub_category objects get included in the results?
$c->addJoin(DocumentationPeer::CATEGORY, CategoryPeer::ID, Criteria::LEFT_JOIN);
$c->addJoin(DocumentationPeer::SUB_CATEGORY, CategoryPeer::alias('c2', CategoryPeer::ID), Criteria::LEFT_JOIN);
$c->addAlias('c2', CategoryPeer::TABLE_NAME);
Done and done!
January 24, 2008 – 4:37pm Installing Symfony on Leopard
I’ve found the best way to install symfony on Leopard is to use the version from SVN. I find this is easy to do, and easy to update in the future. Here is a cheat sheet for those looking to get up and running with symfony on their Mac running 10.5 Leopard. More…
January 21, 2008 – 9:50am svn, apache2, os x leopard 10.5
Mac OS 10.5 Leopard ships with Apache2 and SVN. However, if you want to keep a local svn repository and not use an external svn server (only really useful if you have projects which you will be the only developer), you have to set up the repository yourself. Here is a quick cheat-sheet to help you do just that. More…
January 14, 2008 – 2:55pm symfony propel-load-data
Loading data from fixtures can be extremely useful to pre-populate your database so you have something to test and code with. I frequently use the propel-load-data task in two ways, the first when altering the schema, and the second to add some new data on top of whats in the database.
This will rebuild your db and model from schema.yml, insert the new structure into your db, and load data from the fixtures in /data/fixtures:
./symfony propel-build-all-load frontend
To load in additional data from a specific fixture file, you can use this command:
./symfony propel-load-data frontend dev data/fixtures/[filename].yml append
December 13, 2007 – 12:54am Propel Set Distinct: setDistinct()
Propel’s use of the Criteria class has many unknown features documented deep within the propel API. One of my favorites is setDistinct(), which will add the DISTINCT keyword into the start of your query. This is very useful when you want to create a select menu that presents a list of pre-existing values for a column in your database. More…
November 16, 2007 – 4:57pm Sending Email within Symfony
Symfony allows you to dish off the responsibility of sending an email to another module/action when necessary, which can be great because it can utilize the “view” aspect of the framework so you can store your email formatting (plain text or HTML) as a template just like you would for a regular action.
As I don’t use this functionality that often, I usually forget how to pass parameters over to this other mail action, such as the id of the object I am working with or the recipient’s email address.
Sending Email with a Custom Action
In this example we’ll be sending an lease application notice to the manager of a property. After the application is saved, we want to send an email to the property manager containing the property name and applicant name, and include a link for them to login and view the complete application.
In our “save” action of the “leaseApp” module, right after the application is saved we’ll send off the email, and we can do this (as outlined in the symfony cookbook) by delegating to another action. More…
November 12, 2007 – 11:08pm svn: can’t commit — working copy is missing or not locked
If you accidentally remove a directory from your version-controlled project and try to commit, you will probably get an error similar to this. To fix it, try and remember *not* to remove or move any version-controlled file from the filesystem directly, but rather use the “svn mv” or “svn rm” commands.
To fix it, do an “svn update” in the removed directory’s enclosing directory to restore it, then do a nice “svn rm” on the folder you had originally removed. Finally, do an “svn ci” to save your changes.
October 1, 2007 – 1:38pm Prevent DNS Servers from redirecting local requests
When I start work on a new web project I usually create a new virtualhost on my development machine so that I can access a local version of the site at something like http://myproj/ instead of http://localhost/~myusername/myproj. I use a nice little shell script written by Patrick Gibson called virtualhost.sh that handles this task on OS X. One little snafu I run into depending on my ISP is that their DNS servers will sometimes capture my local request to the domain name and try to redirect before my request even hits my local server. To fix this, you have to edit your local hosts database. Open up /private/etc/hosts and add a line like:
127.0.0.1 myproject
Now, any requests to http://myproject/ should be recognized as a local host and your DNS servers will no longer redirect you.



