Category Archives: Web Development

Lucene PHP – Important Notes

*** Lucene – Use integers *** Actually the book ‘Practical Symfony’ (version jobeet-1.2-propel-en-2009-02-05) is not accurate: 1) the primary key should be defined as a Keyword $doc->addField(Zend_Search_Lucene_Field::Keyword(‘pk’, $this->getId())); 2) by default, Lucene can’t find numbers in its index [and a … Continue reading

Posted in Symfony | Tagged | Leave a comment

Symfony and Eclipse – Include Library

To include Symfony library: ‘Add External Source Library’ during the creation of the project

Posted in Symfony | Tagged | Leave a comment

Symfony – Admin on a Subset of Rows, Extra Criteria

In the actions.class.php, you need to override the method buildCriteria, adding the criteria you need

Posted in Symfony | Leave a comment

Propel – Sympony – Conditions in OR in Criteria

Propel: $c = new Criteria(); $cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, “Leo”); $cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME, array(“Tolstoy”, “Dostoevsky”, “Bakhtin”), Criteria::IN); $cton1->addOr($cton2); // add to Criteria $c->add($cton1); $authors = AuthorPeer::doSelect($c);

Posted in Symfony | Leave a comment

Selenium & PHPunit Tricks

_ -d par=val -> to pass a param _ –filter to execute just some tests from the command line _ use exit from inside a test to freeze the browser – good for debugging http://www.bitmotif.com/selenium/selenium-remote-control-for-java-a-tutorial-part-2/

Posted in Web Development | Tagged | Leave a comment

VBulletin – Make Everything UTF-8

_ MySQL – database charset _ config file – database charset _ Admin -> Languages: HTML Character Set must be UTF-8 _ Check the Meta Equiv is UTF8

Posted in PHP | Tagged | Leave a comment

The Unexpected SQL Injections

http://www.webappsec.org/projects/articles/091007.shtml

Posted in PHP, Web Development | Leave a comment

MySQL Optimization

use ENUM whenever possible do not be too generous with the varchar length NULL columns take more space and make computation harder – avoid using them, use empty strings or zeros. InnoDB-specific. Use a surrogate key which is a primary … Continue reading

Posted in MySQL | Leave a comment

Custom SQL on Symfony

$c = new Criteria(); $c->addAsColumn(‘total_views’, ‘SUM(‘ . self::VIEWS . ‘)’); $c->addAsColumn(‘yearAndMonth’, ‘SUBSTR(‘ . self::TIME . ‘, 1, 7)’); $c->add(self::OFFER_ID, $offer->getId()); $c->addGroupByColumn(‘yearAndMonth’); $c->addDescendingOrderByColumn(‘yearAndMonth’); $viewsForMonths = array(); $stmt = BasePeer::doSelect($c); while($result = $stmt->fetch(PDO::FETCH_ASSOC)) { list($year, $month) = explode(‘-’, $result['yearAndMonth']); $monthString = date(‘F’, … Continue reading

Posted in Symfony | Leave a comment

Symfony – Get the Working Environment

$sf_environment = sfConfig::get(’sf_environment’);

Posted in Symfony | Leave a comment