diff --git a/controller/behavior/taggable.php b/controller/behavior/taggable.php index 84acc17..c5ca5fe 100644 --- a/controller/behavior/taggable.php +++ b/controller/behavior/taggable.php @@ -118,7 +118,7 @@ protected function _appendTags(KModelEntityInterface $entity) $config = array( 'data' => array( 'title' => $tag, - 'row' => $entity->uuid, + 'uuid' => $entity->uuid, ), 'status' => $status, ); diff --git a/database/behavior/taggable.php b/database/behavior/taggable.php index fd99ed2..18c70a5 100644 --- a/database/behavior/taggable.php +++ b/database/behavior/taggable.php @@ -27,7 +27,7 @@ public function getTags() $model = $this->getObject('com:tags.model.tags', array('table' => $package.'_tags')); if(!$this->isNew()) { - $tags = $model->row($this->uuid)->fetch(); + $tags = $model->uuid($this->uuid)->fetch(); } else { $tags = $model->fetch(); } @@ -48,7 +48,7 @@ protected function _beforeSelect(KDatabaseContext $context) { $package = $this->getMixer()->getIdentifier()->package; - $query->join($package.'_tags_relations AS tags_relations', 'tags_relations.row = tbl.uuid'); + $query->join($package.'_tags_relations AS tags_relations', 'tags_relations.uuid = tbl.uuid'); $query->join($package.'_tags AS tags', 'tags.tag_id = tags_relations.tag_id'); $query->where('tags.slug IN :tag'); } diff --git a/model/entity/tag.php b/model/entity/tag.php index e3172ff..0bf8bc7 100644 --- a/model/entity/tag.php +++ b/model/entity/tag.php @@ -27,7 +27,7 @@ public function save() { $result = true; - if($this->row) + if($this->uuid) { $tag = $this->getTable()->select(array('title' => $this->title), KDatabase::FETCH_ROW); @@ -36,7 +36,7 @@ public function save() { //Unset the row property $properties = $this->getProperties(); - unset($properties['row']); + unset($properties['uuid']); $result = $tag->setProperties($properties)->save(); } @@ -46,15 +46,15 @@ public function save() { $data = array( 'tag_id' => $tag->id, - 'row' => $this->row, + 'uuid' => $this->uuid, ); $name = $this->getTable()->getName().'_relations'; $table = $this->getObject('com:tags.database.table.relations', array('name' => $name)); - if (!$table->count($data)) { + if (!$table->count($data)) + { $relation = $table->createRow(array('data' => $data)); - $result = $table->insert($relation); } } @@ -76,8 +76,8 @@ public function delete() $name = $this->getTable()->getName().'_relations'; $table = $this->getObject('com:tags.database.table.relations', array('name' => $name)); - if($this->row) { - $query = array('tag_id' => $this->id, 'row' => $this->row); + if($this->uuid) { + $query = array('tag_id' => $this->id, 'uuid' => $this->uuid); } else { $query = array('tag_id' => $this->id); } @@ -90,7 +90,7 @@ public function delete() } //Delete the tag - if(!$this->row) { + if(!$this->uuid) { $result = parent::delete(); } diff --git a/model/tags.php b/model/tags.php index 9ea280a..0389a72 100644 --- a/model/tags.php +++ b/model/tags.php @@ -26,7 +26,7 @@ public function __construct(KObjectConfig $config) // Set the state $this->getState() - ->insert('row', 'cmd') + ->insert('uuid' , 'cmd') ->insert('created_by', 'int'); } @@ -86,10 +86,10 @@ protected function _buildQueryColumns(KDatabaseQueryInterface $query) 'count' => 'COUNT( relations.tag_id )' )); - if($this->getState()->row) + if($this->getState()->uuid) { $query->columns(array( - 'row' => 'relations.row' + 'uuid' => 'relations.uuid' )); } } @@ -127,8 +127,8 @@ protected function _buildQueryWhere(KDatabaseQueryInterface $query) { $state = $this->getState(); - if($state->row) { - $query->where('relations.row IN :row')->bind(array('row' => (array) $this->getState()->row)); + if($this->getState()->uuid) { + $query->where('relations.uuid IN :uuid')->bind(array('uuid' => (array) $this->getState()->uuid)); } if ($state->created_by) diff --git a/resources/install/example.sql b/resources/install/example.sql index 24f06ca..f7cb5a9 100644 --- a/resources/install/example.sql +++ b/resources/install/example.sql @@ -1,4 +1,3 @@ - -- -------------------------------------------------------- -- @@ -29,6 +28,6 @@ CREATE TABLE `#__tags` ( CREATE TABLE `#__tags_relations` ( `tag_id` bigint(20) unsigned NOT NULL, - `row` VARCHAR(36) NOT NULL, - PRIMARY KEY (`tag_id`,`row`) + `uuid` VARCHAR(36) NOT NULL, + PRIMARY KEY (`tag_id`,`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;