Skip to content

CriteriaApiDistinct

gklp edited this page Aug 9, 2014 · 2 revisions

distinct($column, $alias = null)

Native SQL:

SELECT DISTINCT(name) AS name FROM members;
SELECT DISTINCT(name) AS ALIAS_NAME FROM members;

PHP:

$members = new members(); 
$criteria =  new Criteria($members);
$criteria->distinct("name");
        
print_r($dbservice->select($criteria));
   
$criteria->distinct("name","ALIAS_NAME"); //with alias
   
print_r($dbservice->select($criteria));

OUT:

ArrayList Object
(
    [arrayList:private] => Array
        (
            [0] => members Object
                (
                    [id] => 
                    [name] => Gökalp
                    [className:private] => members
                    [classVars:private] => Array
                        (
                            [0] => id
                            [1] => name
                        )

                )

            [1] => members Object
                (
                    [id] => 
                    [name] => Mikail
                    [className:private] => members
                    [classVars:private] => Array
                        (
                            [0] => id
                            [1] => name
                        )

                )

        )

)

ArrayList Object
(
    [arrayList:private] => Array
        (
            [0] => members Object
                (
                    [id] => 
                    [name] => 
                    [className:private] => members
                    [classVars:private] => Array
                        (
                            [0] => id
                            [1] => name
                        )

                    [ALIAS_NAME] => Gökalp
                )

            [1] => members Object
                (
                    [id] => 
                    [name] => 
                    [className:private] => members
                    [classVars:private] => Array
                        (
                            [0] => id
                            [1] => name
                        )

                    [ALIAS_NAME] => Mikail
                )

        )

)
Clone this wiki locally