ModelGenerator.php 710 B

12345678910111213141516171819202122232425
  1. <?php
  2. class ModelGenerator extends CCodeGenerator
  3. {
  4. public $codeModel='gii.generators.model.ModelCode';
  5. /**
  6. * Provides autocomplete table names
  7. * @param string $db the database connection component id
  8. * @return string the json array of tablenames that contains the entered term $q
  9. */
  10. public function actionGetTableNames($db)
  11. {
  12. if(Yii::app()->getRequest()->getIsAjaxRequest())
  13. {
  14. $all = array();
  15. if(!empty($db) && Yii::app()->hasComponent($db)!==false && (Yii::app()->getComponent($db) instanceof CDbConnection))
  16. $all=array_keys(Yii::app()->{$db}->schema->getTables());
  17. echo json_encode($all);
  18. }
  19. else
  20. throw new CHttpException(404,'The requested page does not exist.');
  21. }
  22. }