コード例 #1
0
ファイル: db.php プロジェクト: demental/m
 public function getByTags($tags, DB_DataObject $obj)
 {
     if (!is_array($tags) || $tags->N) {
         $tags = array($tags);
     }
     foreach ($tags as $atag) {
         if (!($atag = $this->_getTagFromTag($atag))) {
             continue;
         }
         $tagsdo[] = $atag;
     }
     if (!is_array($tagsdo)) {
         // No tag exist, so we should retrieve no record at all,
         $obj->whereAdd('1=2');
         return;
     }
     $obj->selectAs();
     foreach ($tagsdo as $tag) {
         $t = DB_DataObject::factory('tag_record');
         $t->tag_id = $tag->pk();
         $t->tagged_table = $obj->tableName();
         $obj->joinAdd($t, 'inner', 'tags_' . Strings::stripify($tag->__toString(), true));
     }
     return;
 }