X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FSql%2FSqlsqlsrv.php;fp=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FSql%2FSqlsqlsrv.php;h=04ca1c335c2cec341b0214850f24ddfa516308d0;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drush/drush/lib/Drush/Sql/Sqlsqlsrv.php b/vendor/drush/drush/lib/Drush/Sql/Sqlsqlsrv.php new file mode 100644 index 000000000..04ca1c335 --- /dev/null +++ b/vendor/drush/drush/lib/Drush/Sql/Sqlsqlsrv.php @@ -0,0 +1,65 @@ +db_spec['database']) ? 'master' : $this->db_spec['database']; + // Host and port are optional but have defaults. + $host = empty($this->db_spec['host']) ? '.\SQLEXPRESS' : $this->db_spec['host']; + if ($this->db_spec['username'] == '') { + return ' -S ' . $host . ' -d ' . $database; + } + else { + return ' -S ' . $host . ' -d ' . $database . ' -U ' . $this->db_spec['username'] . ' -P ' . $this->db_spec['password']; + } + } + + public function db_exists() { + // TODO: untested, but the gist is here. + $database = $this->db_spec['database']; + // Get a new class instance that has no 'database'. + $db_spec_no_db = $this->db_spec; + unset($db_spec_no_db['database']); + $sql_no_db = drush_sql_get_class($db_spec_no_db); + $query = "if db_id('$database') IS NOT NULL print 1"; + drush_shell_exec($sql_no_db->connect() . ' -Q %s', $query); + $output = drush_shell_exec_output(); + return $output[0] == 1; + } + + public function listTables() { + $return = $this->query('SELECT TABLE_NAME FROM information_schema.tables'); + $tables = drush_shell_exec_output(); + if (!empty($tables)) { + // Shift off the header of the column of data returned. + array_shift($tables); + return $tables; + } + } + + // @todo $file is no longer provided. We are supposed to return bash that can be piped to gzip. + // Probably sqlsrv needs to override dump() entirely. + public function dumpCmd($table_selection) { + if (!$file) { + $file = $this->db_spec['database'] . '_' . date('Ymd_His') . '.bak'; + } + $exec = "sqlcmd -U \"" . $this->db_spec['username'] . "\" -P \"" . $this->db_spec['password'] . "\" -S \"" . $this->db_spec['host'] . "\" -Q \"BACKUP DATABASE [" . $this->db_spec['database'] . "] TO DISK='" . $file . "'\""; + if ($option = drush_get_option('extra', $this->query_extra)) { + $exec .= " $option"; + } + return array($exec, $file); + } + + +}