<?php

namespace app\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use app\base\Converter;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "{{%Dbchange}}".
 *
 * @property integer $id
 * @property string $sid
 * @property string $location
 * @property string $pid
 * @property string $participant_id
 * @property string $interviewer
 * @property string $visit
 * @property string $visit_date
 * @property integer $visit_in
 * @property string $out_interviewer
 * @property integer $visit_out
 * @property string $status
 * @property integer $create_time
 * @property integer $create_user
 * @property integer $update_time
 * @property integer $update_user
 */
class Dbchange extends \yii\db\ActiveRecord
{
     /**
	 * @inheritdoc
	 */
	  
	 
	 public static function getDb()
    {
        // use the "db2" application component
        return \Yii::$app->db2;  
    }
   
    public static function tableName()
	{
		return '{{%dbchange}}';
	}

   public static function RetriveDBName() 
	 {
	 $alldb=array();
	 $dbcn = @mysql_connect ('localhost', 'yrgbs', '(5gVtQ6=h.Hs'); 
     $result = @mysql_query("SHOW DATABASES like '%iccplus%'"); 
      while ($row = mysql_fetch_array($result))
    { 	
      array_push($alldb,$row[0]);           	 
	}	
	
	$all = array_combine($alldb, $alldb);
	//print_r ($all);
	return $all;
 }	
	
	/**
	 * @inheritdoc
	 */
	public function rules()
	{
		return [
			[['dbname'], 'required', 'message' => 'Cannot be blank.'],
			
		];
	}

	
	/**
	 * @inheritdoc
	 */
	public function attributeLabels()
	{
		return [
			'dbname' => Yii::t('app', 'Database Name'),
			
		];
	}

}
