Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added dbConnection detection for User model and db type check #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions migrations/m110805_153437_installYiiUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public function safeUp()
return false;
}
Yii::import('user.models.User');

// initialize user object and set current dbConnection
$this->_model = new User;
$this->_model->db = $this->dbConnection;

//*
switch ($this->dbType()) {
case "mysql":
Expand Down Expand Up @@ -179,7 +184,7 @@ public function safeDown()

public function dbType()
{
list($type) = explode(':',Yii::app()->db->connectionString);
list($type) = explode(':',$this->dbConnection->connectionString);
echo "type db: ".$type."\n";
return $type;
}
Expand All @@ -196,9 +201,6 @@ private function readStdin($prompt, $valid_inputs, $default = '') {
}

private function readStdinUser($prompt, $field, $default = '') {
if (!$this->_model)
$this->_model = new User;

while(!isset($input) || !$this->_model->validate(array($field))) {
echo $prompt.(($default)?" [$default]":'').': ';
$input = (trim(fgets(STDIN)));
Expand Down
2 changes: 1 addition & 1 deletion migrations/m110810_162301_userTimestampFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function safeDown()

public function dbType()
{
list($type) = explode(':',Yii::app()->db->connectionString);
list($type) = explode(':', $this->dbConnection->connectionString);
echo "type db: ".$type."\n";
return $type;
}
Expand Down