私はリチウムの関係で少し曇っています。私はLithiumを使ってタグクラウドを作成しようとしていますが、HABTM関係を使用せずにこれを行う方法がわかりません。 私はMySQL、btwを使用しています。HABTMなしでLtihiumのタグクラウドをコーディングする方法は?
提案がありますか?
:サンプルコードを追加するために編集:ここでは
は、私が今働いている何かの非常に単純化したバージョンです。 私はItems
,Tags
およびItemsTags
です。
<?php
namespace app\models;
class Tags extends \app\extensions\data\Model {
public $hasMany = array('ItemsTags');
// {{{ schema
protected $_schema = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'title' => array('type' => 'string'),
'created' => array('type' => 'integer'),
'modified' => array('type' => 'integer')
);
// }}}
}
?>
<?php
namespace app\models;
class Items extends \app\extensions\data\Model {
public $hasMany = array('ItemsTags');
// {{{ schema
protected $_schema = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'title' => array('type' => 'string'),
'sku' => array('type' => 'string'),
'price' => array('type' => 'float'),
'created' => array('type' => 'integer'),
'modified' => array('type' => 'integer')
);
// }}}
}
?>
<?php
namespace app\models;
class ItemsTags extends \app\extensions\data\Model {
public $belongsTo = array('Tags', 'Items');
// {{{ schema
protected $_schema = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'tag_id' => array('type' => 'integer'),
'item_id' => array('type' => 'integer'),
'created' => array('type' => 'integer'),
'modified' => array('type' => 'integer')
);
// }}}
}
?>
<?php
$items = Items::find('first', array(
'conditions' => array('myField' => 'myCondition')
));
?>
あなたはSQLを使用している場合、私はに見てとる$items
例を挙げてください。 =)私は助けたいが問題を理解できない。 – Tomen
ありがとう。オリジナルの投稿を編集して自分のモデルを表示しました。 – Housni
私はまだこれを理解しようとしています。誰かが私を正しい方向に向けることができればそれは感謝します。 – Housni