Distict no Yii

Galera, to com uma dúvida que não consigo achar em lugar algum.

Tenho no meu banco, a tabela abaixo:


CREATE TABLE `vendas` (

  `id` char(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',

  `pedido` char(32) COLLATE utf8_unicode_ci DEFAULT NULL,

  `numero` int(11) NOT NULL AUTO_INCREMENT,

  `cliente` char(32) COLLATE utf8_unicode_ci NOT NULL,

  `data` date NOT NULL,

  `vendedor` char(32) COLLATE utf8_unicode_ci DEFAULT NULL,

  `forma_venda` tinyint(4) NOT NULL,

  `tipo_venda` tinyint(4) NOT NULL,

  `observacao` text COLLATE utf8_unicode_ci,

  `status` tinyint(4) NOT NULL DEFAULT '0',

  `empenho` char(32) COLLATE utf8_unicode_ci DEFAULT NULL,

  `setor` char(32) COLLATE utf8_unicode_ci NOT NULL,

  `responsavel` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,

)

O caso é com o campo responsavel, que é só um nome texto sem relacionamento algum (E está correto).

O lançe é que eu queria colocar um autoComplete no form pros usuários, pra não ter que digitar o nome do responsável se tiver sido cadastrado antes e talz. No caso, eu consigo recuperar o responsavel (Só ele mesmo) de forma semelhante a fazer um SQL com distinct como abaixo? Não queria fugir de usar AR, se possível.


select distinct responsavel from vendas

Não te dou certeza absoluta, mas acho que vc pode fazer assim:




vendas::model()->findAll(array('select' => 'responsavel', 'distinct' => true))



Perfeito. Vlw a dica :)

É assim mesmo.

http://www.yiiframework.com/doc/api/1.1/CDbCriteria#distinct-detail