锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲一级毛片在线观,亚洲AV永久无码精品一福利,亚洲一区二区高清http://www.tkk7.com/programmer/category/27885.htmlzh-cnFri, 07 Dec 2007 06:21:31 GMTFri, 07 Dec 2007 06:21:31 GMT60How To: Using symfony to add a join between tableshttp://www.tkk7.com/programmer/archive/2007/12/05/165599.htmlwadewadeWed, 05 Dec 2007 09:26:00 GMThttp://www.tkk7.com/programmer/archive/2007/12/05/165599.htmlhttp://www.tkk7.com/programmer/comments/165599.htmlhttp://www.tkk7.com/programmer/archive/2007/12/05/165599.html#Feedback0http://www.tkk7.com/programmer/comments/commentRss/165599.htmlhttp://www.tkk7.com/programmer/services/trackbacks/165599.html1. simple join two tables

purpose:
generate sql like:   

select * from photo p
    left join artist a on p.artist_id = a.artist_id
      where a.genre = 'something' and p.genre = 'something'

code:           

if(!CriteriaUtil::hasJoin($criteria, ArtistPeer::TABLE_NAME)){
    $criteria->addJoin(PhotoPeer::ARTIST_ID, ArtistPeer::ARTIST_ID, Criteria::LEFT_JOIN);
}
$criteria->add(ArtistPeer::GENRE, $genre);    
$criteria->add(PhotoPeer::GENRE, $genre);

2. join two tables, add AND OR between conditions
purpose:
generate sql like:    

select * from photo p
    left join artist a on p.artist_id = a.artist_id
      where (a.genre = 'some' or p.genre='something')
        and a.name = 'something'

code:   

if(!CriteriaUtil::hasJoin($criteria, ArtistPeer::TABLE_NAME)){
   $criteria->addJoin(PhotoPeer::ARTIST_ID, ArtistPeer::ARTIST_ID, Criteria::LEFT_JOIN);
}
$criteria->add(ArtistPeer::GENRE, $genre);
$c = $criteria->getCriterion(ArtistPeer::GENRE);
if($c != null){
   $c->addOr($criteria->getNewCriterion(PhotoPeer::GENRE, $genre));
}
$criteria->add(ArtistPeer::NAME, $name);

 

Note:
It's a good habit to check if we have joined the table already. to check this, you can use the following util class, it get all the joined tables, and check if the table exists in them.

class CriteriaUtil{
    public static function hasJoin($c, $table_name){
        $joins = $c->getJoins();
        if($joins != null){
            foreach($joins as $join){
                if($join->getRightTableName() == $table_name){
                    return true;
                }
                if($join->getLeftTableName() == $table_name){
                    return true;
                }
            }
        }
        return false;
    }
}


wade 2007-12-05 17:26 鍙戣〃璇勮
]]>
How To: Clear cache for symfonyhttp://www.tkk7.com/programmer/archive/2007/11/13/165571.htmlwadewadeTue, 13 Nov 2007 09:23:00 GMThttp://www.tkk7.com/programmer/archive/2007/11/13/165571.htmlhttp://www.tkk7.com/programmer/comments/165571.htmlhttp://www.tkk7.com/programmer/archive/2007/11/13/165571.html#Feedback0http://www.tkk7.com/programmer/comments/commentRss/165571.htmlhttp://www.tkk7.com/programmer/services/trackbacks/165571.htmlOriginal article: http://www.symfony-project.com/book/1_0/18-Performance

Clearing Selective Parts of the Cache

During application development, you have to clear the cache in various situations:

  • When you create a new class: Adding a class to an autoloading directory (one of the project's lib/ folders) is not enough to have symfony find it automatically. You must clear the autoloading configuration cache so that symfony browses again all the directories of the autoload.yml file and references the location of autoloadable classes--including the new ones.
  • When you change the configuration in production: The configuration is parsed only during the first request in production. Further requests use the cached version instead. So a change in the configuration in the production environment (or any environment where SF_DEBUG is turned off) doesn't take effect until you clear the cached version of the file.
  • When you modify a template in an environment where the template cache is enabled: The valid cached templates are always used instead of existing templates in production, so a template change is ignored until the template cache is cleared or outdated.
  • When you update an application with the sync command: This case usually covers the three previous modifications.

The problem with clearing the whole cache is that the next request will take quite long to process, because the configuration cache needs to be regenerated. Besides, the templates that were not modified will be cleared from the cache as well, losing the benefit of previous requests.

That means it's a good idea to clear only the cache files that really need to be regenerated. Use the options of the clear-cache task to define a subset of cache files to clear, as demonstrated in Listing 18-14.

Listing 18-14 - Clearing Only Selective Parts of the Cache

// Clear only the cache of the myapp application
> symfony clear-cache myapp

// Clear only the HTML cache of the myapp application
> symfony clear-cache myapp template

// Clear only the configuration cache of the myapp application
> symfony clear-cache myapp config

You can also remove files by hand in the cache/ directory, or clear template cache files selectively from the action with the $cacheManager->remove() method, as described inChapter 12

 

Note:

1. We can use $cacheManager->remove() to clear cache after we deployed a new version product.

2. write code to generate models from database, and then call $cacheManager->remove() to clear cache.


 


wade 2007-11-13 17:23 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲一区二区三区四区在线观看| 国产禁女女网站免费看| 亚洲成AV人片在线观看无| 亚洲国产免费综合| 亚洲麻豆精品国偷自产在线91| 少妇亚洲免费精品| 国产a v无码专区亚洲av| 特级毛片aaaa级毛片免费| 亚洲第一永久AV网站久久精品男人的天堂AV | 国产91久久久久久久免费| 最新亚洲人成无码网站| 亚洲AV日韩精品一区二区三区| 人妻无码中文字幕免费视频蜜桃| 亚洲精品国产精品国自产观看| caoporn成人免费公开| 亚洲国产成人一区二区三区| 99蜜桃在线观看免费视频网站| 亚洲最大在线视频| 思思99re66在线精品免费观看| 国内成人精品亚洲日本语音| 国产综合精品久久亚洲| 99久久久国产精品免费蜜臀| 国产成人精品日本亚洲直接| 四虎影院免费在线播放| av网站免费线看| 精品日韩亚洲AV无码一区二区三区| 免费无码又黄又爽又刺激| 黄床大片30分钟免费看| 亚洲AV日韩AV永久无码绿巨人| 成人网站免费观看| 亚洲免费一区二区| 亚洲日本视频在线观看| 亚洲A∨午夜成人片精品网站| 毛片在线播放免费观看| 亚洲精品无码少妇30P| 亚洲欧洲日产国码av系列天堂| AV无码免费永久在线观看| 一个人看的www免费高清| 亚洲福利视频网址| 亚洲黄黄黄网站在线观看| 久久国产色AV免费看|