示例#1
0
 public function testPut()
 {
     $tag = new Tag();
     $tag->setId(50);
     $tag->setTitle('test modifié');
     $tagMapper = new TagMapper();
     $tagMapper->setId(50);
     $tagMapper->updateTag($tag);
     $this->assertEquals($tag, $tagMapper->selectTag());
 }
示例#2
0
 /**
  * Get tag by it's name/value.
  *
  * @param $value
  * @return null|Tag
  */
 public function getTagByValue($value)
 {
     $tag = new Tag();
     $tag->setValue($value);
     $query = $this->db->prepare("SELECT * FROM tags WHERE value = :value");
     $query->bindValue(":value", $value);
     $query->setFetchMode(PDO::FETCH_ASSOC);
     $query->execute();
     if ($row = $query->fetch()) {
         $tag->setId($row['tag_id']);
     } else {
         return null;
     }
     return $tag;
 }
示例#3
0
 public function setId($id)
 {
     $this->label->setFor($id);
     parent::setId($id);
 }
示例#4
0
 /**
  * Method for returning list of assigned tags or assigned to the
  * specific person by ID.
  * @param int $personId
  * @return Tag[] Array of Tag objects
  * @throws BadDatabaseQueryException
  */
 public function listAssignedTags($personId = NULL)
 {
     $listOfAssignedTags;
     if (!$personId) {
         $strSQL = "SELECT * FROM tag";
     } else {
         $strSQL = "SELECT * FROM tag WHERE person_id=" . $personId;
     }
     if (!($result = $this->dbh->query($strSQL))) {
         throw new BadDatabaseQueryException("Bad database query!");
     }
     while ($record = $result->fetch_array()) {
         $newTag = new Tag();
         $newTag->setId($record["id"]);
         $newTag->setTagId($record["tagid"]);
         $newTag->setMAC($record["mac"]);
         $listOfAssignedTags[] = $newTag;
     }
     return $listOfAssignedTags;
 }
示例#5
0
 public function create(Tag &$Tag)
 {
     $this->db->query("insert into Tag set\n      \tname='" . $this->db->escape($Tag->getName()) . "',\n        description='" . $this->db->escape($Tag->getDescription()) . "'");
     # Set the newly assigned id
     $Tag->setId($this->db->getLastInsertedId());
 }