Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/behavior/taggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function _appendTags(KModelEntityInterface $entity)
$config = array(
'data' => array(
'title' => $tag,
'row' => $entity->uuid,
'uuid' => $entity->uuid,
),
'status' => $status,
);
Expand Down
4 changes: 2 additions & 2 deletions database/behavior/taggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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');
}
Expand Down
16 changes: 8 additions & 8 deletions model/entity/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
Expand All @@ -90,7 +90,7 @@ public function delete()
}

//Delete the tag
if(!$this->row) {
if(!$this->uuid) {
$result = parent::delete();
}

Expand Down
10 changes: 5 additions & 5 deletions model/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(KObjectConfig $config)

// Set the state
$this->getState()
->insert('row', 'cmd')
->insert('uuid' , 'cmd')
->insert('created_by', 'int');
}

Expand Down Expand Up @@ -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'
));
}
}
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions resources/install/example.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- --------------------------------------------------------

--
Expand Down Expand Up @@ -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;