11 articles Twig & Doctrine Page 2 / 3

Symfony Doctrine’s version of MySQL’s “IN” — as in “values contained in”

MySQL's "IN" query filter is very useful. Basically, if you have a list of record ID numbers, you can query them all neatly like so: The containing comma-delimited list is a simple and neat query that can be assembled in your code quickly. Duplicating MySQL's "IN( )" in Doctrine is just as easy, you…

Symfony and Doctrine’s version of MySQL’s “SELECT FOR UPDATE” queries

Sometimes, you may find yourself needing to select a value or record from a database and hold that record so you can update it without any other process intervening. There are a lot of instances you may need to "lock" the record to a process to ensure no other process can "claim" it as well.…

Creating a credit card month/year form field input in Symfony 2.5

Creating a credit card month/year input can be accomplished with a single database field but Symfony is smart enough to create multiple pull downs for each.  It is NOT smart enough to not require the programmer to exclude the "day" value.  So, what do you do?  There are many workarounds, including using some post rendering…

Symfony2 Twig: Conditionally display form errors in Twig views

This will only show form errors if there are any in your form view.

Outputting PHP “var_dump” code debug capability inside Twig templates

Twig comes with its own Debug extension to allow users to output "var_dump()" -- the function that spits out the raw values behind a PHP variable, array or object -- inside a Twig template.  This functions is helpful in the dev environment while trying to debug code.   Step 1:  Add the following to the…