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; } }
29 de agosto de 2011
Propel get average - mysql AVG
Here's how to do it:
26 de agosto de 2011
Using CKEditor and CKFinder
- Download the sfCKEditorPlugin plugin
- Go to http://ckeditor.com/ and download the last version.
- Put the ckeditor folder to the web\js folder.
- Go to http://ckfinder.com/ and download the last version.
- Put the ckfinder folder to the web\js folder.
- Add sfCKEditorPlugin to the ProjectConfiguration.class.php
- Open app.yml (apps/frontend or backend/config..) and put:
# sfCKEditorPlugin
ckeditor:
basePath: /js/ckeditor
ckfinder:
active: true
basePath: /js/ckfinder - Create config/autoload.yml:
autoload:
ckeditor:
name: ckeditor
path: %sf_web_dir%/js/ckeditor
recursive: on
ckfinder:
name: ckfinder
path: %sf_web_dir%/js/ckfinder
recursive: on - Add js files to the view.yml in this way:
javascripts: [ckeditor/ckeditor.js, ckfinder/ckfinder.js] - Edit /js/ckfinder/config.php... find CheckAuthentication() method and modify it toreturn true; however read the comments, it can be dangerous!
- Change the $baseUrl to /uploads/ckfinder/ in ckfinder's config.php
- Type symfony cc to clear the cache.
- Use the following syntax to call CKEditor:
$this->widgetSchema['my_editor'] = new sfWidgetFormCKEditor();
From: http://sakrawebstudio.blogspot.com/2010/10/install-ckeditor-and-ckfinder-in.html
1 de agosto de 2011
Where did a certain query originated?
Easy way of tracking every sql query under sf's the web debug toolbar:
#factories.yml:
Result:
#factories.yml:
dev: logger: param: loggers: sf_web_debug: param: xdebug_logging: true
Result:
Assinar:
Postagens (Atom)