Archive

Posts Tagged ‘doctrine’

Using Memcached with Symfony 1.2 and Doctrine

September 15th, 2009

Make sure you have Memcached installed.

Add this to ProjectConfiguration.class.php

//ProjectConfiguration.class.php
    public function configureDoctrine(Doctrine_Manager $manager) {
 
        $servers = array(
            'host' => 'localhost',
            'port' => 11211,
            'persistent' => true
        );
 
 
        $cacheDriver = new Doctrine_Cache_Memcache(array(
            'servers' => $servers,
            'compression' => false
            )
        );
 
        //enable Doctrine cache
        $manager = Doctrine_Manager::getInstance();
 
 
 
        $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver);
 
    }

Add this to your query

 ->useResultCache(true);

Mariusz Actions ,

Creating thumbnails with sfThumbnailPlugin and doctrine

February 3rd, 2009
 
public function set($name, $value, $load = true)
{
            parent::set($name, $value, $load);
            if($name == 'file')
                $this->generateThumbnail($value);
            }
 
public function generateThumbnail($value)
{
            $uploadDir = sfConfig::get('sf_upload_dir');
            $loadDir = $uploadDir;
            $thumbnail = new sfThumbnail(150, 150);
            $thumbnail->loadFile($loadDir.$value);
            $thumbnail->save($uploadDir.'/thumbs/'.$value, 'image/jpeg');
     }

Mariusz Model ,