We have a new blog over at
http://it.blog.adclick.pt
http://it.blog.adclick.pt
All posts from this blog were transferred.
Hope to see you there!
public function getAverageRating()
{
$c = new Criteria;
$c->addSelectColumn('avg(' . RatingPeer::RATING . ')');
$c->add(RatingPeer::ID, $this->getId());
$stmt = RatingPeer::doSelectStmt($c);
$average = $stmt->fetchAll(PDO::FETCH_COLUMN);
if(array_key_exists(0, $average)) {
return floatval($average[0]);
}
else
{
return 0;
}
}
dev:
logger:
param:
loggers:
sf_web_debug:
param:
xdebug_logging: trueSymfony Nosso que estais no svn,Décio @ Yammer
santificado seja o vosso php,
vem a nós o vosso MVC,
seja feita a vossa aplicação
assim na terra como na web.
A cache nossa de cada dia nos daí hoje,
perdoai-nos os nossos bugs,
assim como nós perdoamos
ao Ti Nano,
não nos deixei cair em tentação
mas livrai-nos do Ruby.
Amém.
$category = 'Pastéis de Nata'; $url = Doctrine_Inflector::urlize($category); echo $url;
pasteis-de-nata
class YourFormFilter extends BaseYourFormFilter {
public function setup() {
// ...
$context = sfContext::getInstance(); /* @var $context sfContext */
$request = $context->getRequest(); /* @var $request sfWebRequest */
$user = $context->getUser(); /* @var $user sfBasicSecurityUser */
if ($user->hasCredential('credential_to_check')) {
$this->setWidget('your_field', new sfWidgetFormFilterInput());
$this->setValidator('your_field', new sfValidatorPass(array('required' => false)));
$this->widgetSchema->moveField('your_field', sfWidgetFormSchema::AFTER, 'other_field'); // this is good to re-arrange the filters order
}
}
// ...
propel:
_attributes: { package: plugins.sfGuardPlugin.lib.model }
##
# extending sfGuard
##
sf_guard_user:
_attributes: { phpName: sfGuardUser }
coisas: { type: varchar, size: 128, required: true }php symfony propel:build --all-classes
You may also use Doctrine extensions:
Finally, there are also symfony plugins providing custom behaviors:
_componentName: enabled: false
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in /blablabla/lib/vendor/symfony/lib/log/sfVarLogger.class.php on line 170
task:
symfony:
param:
profiler: false
all:
symfony:
class: sfDoctrineDatabase
param:
dsn: ....
username: ...
password: ...$this->getRequest()->getParameterHolder()->getAll();
As of version 5.2.5, PHP is not able to garbage collect object graphs that have circular references, e.g. Parent has a reference to Child which has a reference to Parent. Since many doctrine model objects have such relations, PHP will not free their memory even when the objects go out of scope.
$meu_objecto->free();
unset($meu_objecto);
//memory check
$memOld = $memNow;
$memNow = memory_get_usage();
$this->log('Memory usage: ' . $memNow . ' (diff=' . ($memNow - $memOld) . ')';
/* @var $dc Doctrine_Collection */
$dc = new Doctrine_Collection('City');
for ($i=1;$i<=32;$i++)
{
$record = new City();
$record->setName('City #' .$i);
$dc->add($record);
}
$this->cities = $dc;
$this->getContext()->getI18N()->__("texto");class frontendConfiguration extends sfApplicationConfiguration {
public function configure()
{
$this->loadHelpers(array('I18N'));
}
}
public function isFirstRequest()
{
$first_request_parameter = $this->getAttribute('first_request');
if (isset($first_request_parameter)) {
return false;
}
$this->setAttribute('first_request', true);
return true;
}...
if ($this->getUser()->isFirstRequest()) {
// primeira visita
} else {
// re-visita
}
protected function configure()
{
$this->addOptions(array(
new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED,'The application name', 'frontend'),
// ...
));
}(Neste caso defini a aplicação default como sendo frontend)protected function execute($arguments = array(), $options = array())
{
// ...
$contextInstance = sfContext::createInstance($this->configuration);
$contextInstance->getConfiguration()->loadHelpers('Partial');
// ...
}
public function executeShow(sfWebRequest $request)
{
sfConfig::set('sf_web_debug', false);
}class TransactionForm extends BaseTransactionForm {
public function configure() {
$this->mergePostValidator(
new sfValidatorSchemaCompare('source_id',
sfValidatorSchemaCompare::NOT_EQUAL,
'destination_id',
array(),
array('invalid' => 'Source and Destination Accounts cannot be the same.')));
}
}
sfProjectConfiguration::getActive()->loadHelpers("Partial", "Url", "MyHelper");