Using CAutoComplete with Database


I've been struggling with this all day and have given up and asking for some help.  The example application of CAutoComplete from this post works fine when passing it the array.


But, when I try to pass it data from a database, I get nothing.  I'm thinking something is not formated correctly in the array.

Here is my code and I would appreciate any help.

public function actionSuggest()


	if(Yii::app()->request->isAjaxRequest && isset($_GET['q']))



		echo implode("n",$results);



protected function getApiSuggestions($search)





	$sql ="SELECT * FROM auto_comp";  //will get everything for now


	$result = $command->query($sql); 

	$results = $result->readAll(); 





	//$results= array('waterloo', 'Waterford', 'Guelph,ON,Ward','Waterloo,ON,Lakeshore');  //it works if this array is passed




	foreach($results as $keyword)






	return $results;

Try directly accessing the 'suggest' action in your browser (remove that isAjaxRequest temporarily)?

Thanks Qiang, just figured it out.  I was accessing the array at the wrong level.