getCountSubquery() public méthode

Returns the count subquery for DataModel's has() and whereHas() methods.
public getCountSubquery ( string $tableAlias = null ) : JDatabaseQuery
$tableAlias string The alias of the local table in the query. Leave blank to use the table's name.
Résultat JDatabaseQuery
Exemple #1
0
    /**
     * @group           BelongsToMany
     * @group           BelongsToManyGetCountSubquery
     * @covers          FOF30\Model\DataModel\Relation\BelongsToMany::getCountSubquery
     */
    public function testGetCountSubquery()
    {
        $model = new Groups(static::$container);
        $relation = new BelongsToMany($model, 'Parts');
        $result = $relation->getCountSubquery();
        $check = '
SELECT COUNT(*)
FROM `#__fakeapp_parts` AS `reltbl`
INNER JOIN `#__fakeapp_parts_groups` AS `pivotTable` ON(`pivotTable`.`fakeapp_part_id` = `reltbl`.`fakeapp_part_id`)
WHERE `pivotTable`.`fakeapp_group_id` =`#__fakeapp_groups`.`fakeapp_group_id`';
        $this->assertInstanceOf('\\JDatabaseQuery', $result, 'BelongsToMany::getCountSubquery Should return an instance of Query');
        $this->assertEquals($check, (string) $result, 'BelongsToMany::getCountSubquery Failed to return the correct query');
    }