Welcome Guest, Not a member yet? Register   Sign In
[suggestion] Know if database exists
#1

[eluser]Ñuño Martínez[/eluser]
I know, there's the method $this->dbutil->database_exists ('name');. The problem is when you need to know if the default database (the one defined at config/database.php) exists. For example, you're creating an installation script. I haven't find a nice way to know which database are configured at configuration file.

Finally I've found this way:
Code:
# Comprueba si la base de datos está creada.
      include APPPATH.'config/database.php'; # Niños:  ¡NO hagáis esto en casa!
      $this->load->dbutil ();
      $this->BDDCreada = $this->dbutil->database_exists ($db['Redsoc']['database']);

But I think that "include" isn't a good solution. I think that add a way to access to the $db array items using a CI function (for example, from dbutil) is much better. For example, the previous code may looks like next one:
Code:
# Comprueba si la base de datos está creada.
      $this->load->dbutil ();
      $db = $this->dbutil->db ('Redsoc');
      $this->BDDCreada = $this->dbutil->database_exists ($db['database']);

Also access to the $active_group variable would be great (i.e. $this->dbutil->active_group ()).
Just as suggestion.
#2

[eluser]InsiteFX[/eluser]
You can use the native MySQLi methods
#3

[eluser]Ñuño Martínez[/eluser]
I know, but what if I want to support various MDBS?
#4

[eluser]InsiteFX[/eluser]
Take a look at the PYRO CMS it has it's own installer




Theme © iAndrew 2016 - Forum software by © MyBB