1)Editor.PHP 來自: 1 2 3 4 | public function pkey ( $_=null )
{
return $this->_getSet( $this->_pkey, $_ );
}
|
至: 1 2 3 4 五 6 7 8 9 | public function pkey ( $_=null )
{
return $this->_getSet( $this->_pkey, $_ );
}
public function distinct ($_=null)
{
return $this->_getSet( $this->_distinct, $_ );
}
|
在我改變的同一個文件中: 來自: 1 2 3 4 五 6 7 | private function _get( $id=null, $http=null )
{
$query = $this->_db
->query("select")
->table( $this->_table )
->get( $this->_pkey );
|
至: 1 2 3 4 五 6 7 8 9 10 | private function _get( $id=null, $http=null )
{
$query = $this->_db
->query("select")
->table( $this->_table )
->get( $this->_pkey );
if ($this->distinct())
$query->distinct(true);
|
為了使rowcount正確,我在下一個地方添加了相同的不同條件: 1 2 3 4 五 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // Get the number of rows in the result set
$ssp_set_count = $this->_db
->query('select')
->table( $this->_table )
->get( 'COUNT('.$this->_pkey.') as cnt' );
if ($this->distinct())
$query->distinct(true);
$this->_get_where( $ssp_set_count );
$this->_ssp_filter( $ssp_set_count, $http );
$this->_perform_left_join( $ssp_set_count );
$ssp_set_count = $ssp_set_count->exec()->fetch();
// Get the number of rows in the full set
$ssp_full_count = $this->_db
->query('select')
->table( $this->_table )
->get( 'COUNT('.$this->_pkey.') as cnt' );
if ($this->distinct())
$query->distinct(true);
|
完成所有這些後,我使用了我的編輯器實例,如下所示: 1 2 3 4 五 6 7 8 9 10 | $editor=Editor::inst( $db, 'jobs' )
->fields(
Field::inst( 'company.Name' ),
Field::inst( 'stores.short_add' )->validator( 'Validate::notEmpty' ),
......
)
->LeftJoin(......);
$editor->distinct(true); //Only add this line if you want distinct values!
$editor->where(.....);
$editor->on(.....);
|
|