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.


Messages In This Thread
[suggestion] Know if database exists - by El Forum - 12-17-2013, 11:36 AM
[suggestion] Know if database exists - by El Forum - 12-26-2013, 03:14 PM
[suggestion] Know if database exists - by El Forum - 12-27-2013, 03:04 AM
[suggestion] Know if database exists - by El Forum - 12-27-2013, 05:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB