Skip to content

Instantly share code, notes, and snippets.

@yexingzhe
Created April 20, 2013 00:51
Show Gist options
  • Save yexingzhe/5424229 to your computer and use it in GitHub Desktop.
Save yexingzhe/5424229 to your computer and use it in GitHub Desktop.
class GoController extends Controller {
{
public function actionGo(){
$criteria = new CDbCriteria;
$criteria->group = 'pinyinma';
$model = Hanzi::model()->findAllByAttributes(array(), $criteria);
$count =0;
$hanzi_array = array();
foreach ($model as $data) {
$count++;
$hanzi_array[$data->pinyinma] = $this->Pinyin($data->pinyinma);
}
// echo $count;
print_r($hanzi_array);
}
public function Pinyin($pinyinma){
$criteria = new CDbCriteria;
$criteria->condition = "pinyinma like '".$pinyinma."'";
$model = Hanzi::model()->findAllByAttributes(array(), $criteria);
$str = '';
foreach ($model as $key => $value) {
$str.=$value->hanzi;
}
return $str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment