Now I have no validation. I have Model/Tag and tag table.
Controller/TagController
<?php
App::uses('AppController', 'Controller');
/*App::uses('Article', 'Model');
App::uses('Link', 'Model');
App::uses('User', 'Model');*/
// with some model , sql is extending so I fell it commented out is better.
/**
* Tags Controller
*
* @property Tag $Tag
* @property PaginatorComponent $Paginator
*/
class TagsController extends AppController {
public $uses = array(//'Tag','Article','Link','User'
);
$this->Paginator->settings = array(
'conditions'=> array(
"Link.LFrom = $id"
),
'fields' => array( 'Link.*'),
Now cake run this sql
SELECT Link
.* FROM db0tagplus
.tag
AS Tag
WHERE Link
.LFrom
= 2152 LIMIT 20
Table relation is very complexed so I can not use assosiation.
how to generate this sql?
SELECT `Link`.* FROM `Link` WHERE `Link`.`LFrom` = 2152 LIMIT 20
I guess, if I could unload model and table 'Tag' It will be OK.
I cannot solve it with unbind.(bind is asssosiation matter).
App::import
and app::use
is loading model order, how to unload specified model?
Solved like this
$this->loadModel('Article');
$this->Paginator->settings = array(
'conditions'=> array(
"Link.LTo = Article.ID"
),
'fields' => array('Link.*','taglink.*','Article.*'
),
'joins'
=> array(
array(
'table' => 'Link',
'type' => 'INNER',
'conditions' => array(
array("$id = Link.LFrom")
)
),
array(
'table' => 'Link',
'alias' => 'taglink',
'type' => 'INNER',
'conditions' => array(
array("Link.ID = taglink.LTo"),
array("$trikeyID = taglink.LFrom")
)
),
)
);
debug($this->Paginator->paginate('Article'));
$this->set('results',$this->Paginator->paginate('Link'));