Skip to content

Instantly share code, notes, and snippets.

View hartym's full-sized avatar
👽
Crafting great software

Romain Dorgueil hartym

👽
Crafting great software
View GitHub Profile
<?php
class xxComponents extends sfComponents
{
public function executeMachin(sfWebRequest $request)
{
$this->addRequiredProperty('form', 'sfForm');
$this->form->...()
}
Index: test/unit/config/sfProjectConfigurationTest.php
===================================================================
--- test/unit/config/sfProjectConfigurationTest.php (revision 21889)
+++ test/unit/config/sfProjectConfigurationTest.php (working copy)
@@ -3,14 +3,14 @@
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <[email protected]>
- *
+ *
#!/bin/sh
SESSIONNAME=romain
if [ "$1" = "" ]; then
echo "Usage: ssc <host>"
exit
fi
ssh $1 -t if \[ \"\`screen -ls \| grep $SESSIONNAME \| wc -l\`\" -gt 0 \]\; then screen -RD $SESSIONNAME\; else screen -S $SESSIONNAME\; fi
Index: lib/Doctrine/Cli.php
===================================================================
--- lib/Doctrine/Cli.php (revision 5937)
+++ lib/Doctrine/Cli.php (working copy)
@@ -21,7 +21,7 @@
/**
* Command line interface class
- * Interface for easily executing Doctrine_Task classes from a
+ * Interface for easily executing Doctrine_Task classes from a
GOOD ONE:
Array
(
[0] => m2.id
[1] => =
[2] => m1.m2_id
)
WRONG ONE:
<?php
class Doctrine_Ticket_9999_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
$this->tables[] = "Model1";
$this->tables[] = "Model2";
parent::prepareTables();
}
--- Buggy SQL:
SELECT c.id AS c__id, c.category_id AS c__category_id, c.name AS c__name, c.description AS c__description, c.need_validation_flag AS c__need_validation_flag, c.advertise_flag AS c__advertise_flag, c.created_at AS c__created_at, c.updated_at AS c__updated_at, c.slug AS c__slug, c2.id AS c2__id, c2.user_id AS c2__user_id, c2.resource_id AS c2__resource_id, c2.validator_id AS c2__validator_id, c2.information AS c2__information, c2.status AS c2__status, c2.visible_details_flag AS c2__visible_details_flag, c2.validated_at AS c2__validated_at, c2.starting_at AS c2__starting_at, c2.ending_at AS c2__ending_at, c2.created_at AS c2__created_at, c2.updated_at AS c2__updated_at FROM booking_resource c LEFT JOIN booking_entry c2 ON (c.id = c2.resource_id AND ((c2.ending_at > '1242691200' AND c2.ending_at <=) OR (c2.starting_at < '1245369600' AND c2.starting_at >= '1242691200') OR (c2.starting_at < '1242691200' AND c2.ending_at >))) WHERE c.category_id = '1' ORDER BY c2.starting_at
--- Good SQL:
SELEC
// WITH SPACE: BUGGY
$result = $this
->createQuery('r')
->select('r.*, e.*')
->from('BookingResource r')
->leftJoin(
'r.Entries e ON '.
'( r.id = e.resource_id AND '.
'( ( e.ending_at > :start AND e.ending_at <= :end ) OR '.
$result = $this
->createQuery('r')
->select('r.*, e.*')
->from('BookingResource r')
->leftJoin(
'r.Entries e ON '.
'( ( e.ending_at > :start AND e.ending_at <= :end ) OR '.
' ( e.starting_at < :end AND e.starting_at >= :start ) OR '.
' ( e.starting_at < :start AND e.ending_at > :end ) )'
)
<?php
class myForm extends sfFormDoctrine
{
public function processValues($values = null)
{
$values = parent::processValues($values);
// calculate the value of virtual field "foo"
$values['foo'] = $foo;
return $values;