Created
April 20, 2013 00:51
-
-
Save yexingzhe/5424229 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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