Example #1
0
 public static function addTags(RedBean_OODBBean $bean, $tagList)
 {
     if ($tagList !== false && !is_array($tagList)) {
         $tags = explode(",", (string) $tagList);
     } else {
         $tags = $tagList;
     }
     if ($tagList === false) {
         return;
     }
     foreach ($tags as $tag) {
         $t = RedBean_Facade::findOne('tag', ' title = ? ', array($tag));
         if (!$t) {
             $t = RedBean_Facade::dispense('tag');
             $t->title = $tag;
             RedBean_Facade::store($t);
         }
         RedBean_Facade::associate($bean, $t);
     }
 }