Post::getCategories PHP Method

getCategories() public method

public getCategories ( ) : mixed
return mixed
    public function getCategories()
    {
        return Yii::app()->db->createCommand()->select('cc.name, bp.category_id, count(bp.id) cnt, cc.slug, cc.description')->from('yupe_blog_post bp')->join('yupe_category_category cc', 'bp.category_id = cc.id')->where('bp.category_id IS NOT NULL')->group('bp.category_id')->having('cnt > 0')->order('cnt DESC')->queryAll();
    }

Usage Example

Example #1
0
 /**
  * @covers stojg\puny\models\Post::getCategories
  * @covers stojg\puny\models\Post::setCategories
  * @covers stojg\puny\models\Post::setMetadata
  */
 public function testGetCategories()
 {
     $expected = array(0 => 'quiz', 1 => 'bar');
     $this->assertEquals($expected, $this->object->getCategories());
     $this->object->setCategories('one,two,three');
     $this->assertEquals(array('one', 'two', 'three'), $this->object->getCategories());
 }
All Usage Examples Of Post::getCategories