This repository has been archived by the owner. It is now read-only.

Added some method inside JDatabaseDriver to create database and alter character set #1261

Closed
wants to merge 7 commits into
from

Conversation

Projects
None yet
5 participants
@gpongelli
Contributor

gpongelli commented Jun 7, 2012

Added two public method inside JDatabaseDriver:

  • alterDbCharacterSet to change database's character set
  • createDatabase to create a new database

AlterDbCharacterSet needs database name as parameter, createDatabase
needs a JObject, similar to that used inside CMS' "initialise" function,
and a bool to set UTF8 database's support.

They use two protected method to obtain correct query in database's
supported syntax:

  • getAlterDbCharacterSet
  • getCreateDatabaseQuery

Protected method inside JDatabaseDriver return query for MySQL and
MySQLi syntax, this commit contain also overridden version for
PostgreSQL database.

There are tests only for protected methods inside MySQL, MySQLi and
PostgreSQL test classes.

gpongelli added some commits Jun 7, 2012

Added two public method inside JDatabaseDriver:
- alterDbCharacterSet to change database's character set
- createDatabase to create a new database

AlterDbCharacterSet needs database name as parameter, createDatabase
needs a JObject, similar to that used inside CMS' "initialise" function,
and a bool to set UTF8 database's support.

They use two protected method to obtain correct query in database's
supported syntax:
- getAlterDbCharacterSet
- getCreateDatabaseQuery

Protected method inside JDatabaseDriver return query for MySQL and
MySQLi syntax, this commit contain also overridden version for
PostgreSQL database.

There are tests only for protected methods inside MySQL, MySQLi and
PostgreSQL test classes.
libraries/joomla/database/driver.php
+ return $this->execute();
+ }
+
+

This comment has been minimized.

@elinw

elinw Jun 10, 2012

Contributor

Extra blank line here. 443 and 444 also have white space.

@elinw

elinw Jun 10, 2012

Contributor

Extra blank line here. 443 and 444 also have white space.

libraries/joomla/database/driver.php
+
+ return $query;
+ }
+

This comment has been minimized.

@elinw

elinw Jun 10, 2012

Contributor

This line 574 has white space.

@elinw

elinw Jun 10, 2012

Contributor

This line 574 has white space.

@gpongelli

This comment has been minimized.

Show comment
Hide comment
@gpongelli

gpongelli Jun 11, 2012

Contributor

Added style fixes and checks for createDatabase method.

Contributor

gpongelli commented Jun 11, 2012

Added style fixes and checks for createDatabase method.

gpongelli added some commits Jun 11, 2012

@stefanneculai

This comment has been minimized.

Show comment
Hide comment
@stefanneculai

stefanneculai Jun 18, 2012

I think it should be &$columns - there is a coding style error.

Doc comment for var $columns does not match actual variable name &$columns at position 1

I think it should be &$columns - there is a coding style error.

Doc comment for var $columns does not match actual variable name &$columns at position 1

This comment has been minimized.

Show comment
Hide comment
@gpongelli

gpongelli Jun 20, 2012

Owner
Owner

gpongelli replied Jun 20, 2012

@gpongelli

This comment has been minimized.

Show comment
Hide comment
@gpongelli

gpongelli Jun 22, 2012

Contributor

Fixed.

Eng. Gabriele Pongelli

Contributor

gpongelli commented Jun 22, 2012

Fixed.

Eng. Gabriele Pongelli

libraries/joomla/database/driver.php
+ {
+ throw new RuntimeException('$options object must not be null.');
+ }
+ elseif (!isset($options->db_name) || empty($options->db_name))

This comment has been minimized.

@realityking

realityking Jul 18, 2012

Contributor

I think this can be simplified to just the empty() check.

@realityking

realityking Jul 18, 2012

Contributor

I think this can be simplified to just the empty() check.

This comment has been minimized.

@gpongelli

gpongelli Jul 19, 2012

Contributor

Changed, I'll commit.

@gpongelli

gpongelli Jul 19, 2012

Contributor

Changed, I'll commit.

libraries/joomla/database/driver.php
+ {
+ throw new RuntimeException('$options object must have db_name set.');
+ }
+ elseif (!isset($options->db_user) || empty($options->db_user))

This comment has been minimized.

@realityking

realityking Jul 18, 2012

Contributor

Same as above.

@realityking

realityking Jul 18, 2012

Contributor

Same as above.

libraries/joomla/database/driver.php
+ * Create a new database using information from $options object, obtaining query string
+ * from protected member.
+ *
+ * @param JObject $options JObject coming from CMS' "initialise" function to pass user

This comment has been minimized.

@realityking

realityking Jul 18, 2012

Contributor

We don't actually need a JObject here. A generic object will do. Also please don't base you comment based on CMS use but be generic.

@realityking

realityking Jul 18, 2012

Contributor

We don't actually need a JObject here. A generic object will do. Also please don't base you comment based on CMS use but be generic.

@gpongelli

This comment has been minimized.

Show comment
Hide comment
@gpongelli

gpongelli Jul 21, 2012

Contributor

Committed changes.

Gabriele.

Contributor

gpongelli commented Jul 21, 2012

Committed changes.

Gabriele.

gpongelli added some commits Jul 21, 2012

Simplified checks.
Changed input parameter comment to generic object.
@ianmacl

This comment has been minimized.

Show comment
Hide comment
@ianmacl

ianmacl Aug 14, 2012

Contributor

So what's the point of public function alterDbCharacterSet($dbName) ?

Contributor

ianmacl commented Aug 14, 2012

So what's the point of public function alterDbCharacterSet($dbName) ?

@gpongelli

This comment has been minimized.

Show comment
Hide comment
@gpongelli

gpongelli Aug 15, 2012

Contributor

Hi Ian,
I added that method because it's used during CMS installation, as createDatabase one, to complete installation on Postgresql.
These methods were born after a private discussion with Andrew, who point me adding these methods here.

Gabriele.

Contributor

gpongelli commented Aug 15, 2012

Hi Ian,
I added that method because it's used during CMS installation, as createDatabase one, to complete installation on Postgresql.
These methods were born after a private discussion with Andrew, who point me adding these methods here.

Gabriele.

@elinw

This comment has been minimized.

Show comment
Hide comment
@elinw

elinw Oct 18, 2012

Contributor

Can you update your branch please?

Contributor

elinw commented Oct 18, 2012

Can you update your branch please?

@gpongelli

This comment has been minimized.

Show comment
Hide comment
@gpongelli

gpongelli Oct 21, 2012

Contributor

updated HERE, I'll close this pull.

Contributor

gpongelli commented Oct 21, 2012

updated HERE, I'll close this pull.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.