Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
provision
Commits
e41bbf05
Commit
e41bbf05
authored
Mar 17, 2010
by
Adrian Rossouw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
holy shit. i verified a platform.. yay me.
parent
c7327115
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
db/db.drush.inc
db/db.drush.inc
+7
-7
db/mysql/mysql_service.inc
db/mysql/mysql_service.inc
+7
-5
No files found.
db/db.drush.inc
View file @
e41bbf05
...
...
@@ -294,14 +294,14 @@ class provisionService_db_pdo extends provisionService_db {
function
__construct
(
$creds
)
{
parent
::
__construct
(
$creds
);
print_r
(
$creds
);
$this
->
dsn
=
sprintf
(
"%s:dbname=%s;host=%s"
,
$this
->
PDO_type
,
$this
->
creds
[
'name'
],
$this
->
creds
[
'host'
]);
}
function
connect
()
{
try
{
$this
->
conn
=
new
PDO
(
$
constr
,
$
creds
[
'user'
],
$creds
[
'pass'
]);
$this
->
conn
=
new
PDO
(
$
this
->
dsn
,
$this
->
creds
[
'user'
],
$
this
->
creds
[
'pass'
]);
}
catch
(
PDOException
$e
)
{
return
drush_set_error
(
'PROVISION_DB_CONNECT_FAIL'
,
$e
->
getMessage
());
...
...
@@ -312,16 +312,16 @@ class provisionService_db_pdo extends provisionService_db {
$this
->
conn
=
null
;
}
function
query
()
{
function
query
(
$query
)
{
$args
=
func_get_args
();
array_shift
(
$args
);
if
(
isset
(
$args
[
0
])
and
is_array
(
$args
[
0
]))
{
// 'All arguments in one array' syntax
$args
=
$args
[
0
];
}
$this
->
query_callback
(
$args
,
TRUE
);
$query
=
preg_replace_callback
(
PROVISION_QUERY_REGEXP
,
array
(
$this
,
'query_callback'
),
$query
);
print_r
(
$query
);
try
{
$result
=
$this
->
conn
->
query
(
$query
);
}
...
...
@@ -334,7 +334,7 @@ class provisionService_db_pdo extends provisionService_db {
}
private
function
query_callback
(
$match
,
$init
=
FALSE
)
{
function
query_callback
(
$match
,
$init
=
FALSE
)
{
static
$args
=
NULL
;
if
(
$init
)
{
$args
=
$match
;
...
...
@@ -345,7 +345,7 @@ class provisionService_db_pdo extends provisionService_db {
case
'%d'
:
// We must use type casting to int to convert FALSE/NULL/(TRUE?)
return
(
int
)
array_shift
(
$args
);
// We don't need db_escape_string as numbers are db-safe
case
'%s'
:
return
$this
->
conn
->
quote
(
array_shift
(
$args
));
return
substr
(
$this
->
conn
->
quote
(
array_shift
(
$args
))
,
1
,
-
1
)
;
case
'%%'
:
return
'%'
;
case
'%f'
:
...
...
db/mysql/mysql_service.inc
View file @
e41bbf05
...
...
@@ -5,22 +5,24 @@
// extends the pdo implementation
class
provisionService_db_mysql
extends
provisionService_db_pdo
{
static
public
$PDO_type
=
'mysql'
;
public
$PDO_type
=
'mysql'
;
function
database_exists
(
$name
)
{
$result
=
$this
->
query
(
"SHOW DATABASES LIKE %s"
,
$name
);
return
$result
->
fetchColumn
(
0
);
$result
=
$this
->
query
(
"SHOW DATABASES LIKE '%s'"
,
$name
);
if
(
$result
)
{
return
$result
->
fetchColumn
(
0
);
}
}
function
drop_database
(
$name
)
{
return
$this
->
query
(
"DROP DATABASE %s"
,
$name
);
return
$this
->
query
(
"DROP DATABASE
`
%s
`
"
,
$name
);
}
function
create_database
(
$name
)
{
return
$this
->
query
(
"CREATE DATABASE %s"
,
$name
);
return
$this
->
query
(
"CREATE DATABASE
`
%s
`
"
,
$name
);
}
function
can_create_database
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment