Created
December 16, 2010 20:30
-
-
Save tomaskavalek/743961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public static function init($options = NULL) { | |
if(is_null($options) || !is_array($options)) return FALSE; | |
if(is_array(current($options))) { | |
foreach($options as $option) { | |
dibi::connect($option, self::CONNECTION . self::$connection++); | |
} | |
} else { | |
dibi::connect($options, self::CONNECTION . self::$connection++); | |
} | |
} | |
$options = array( | |
array( | |
'driver' => 'mysql', | |
'host' => 'localhost', | |
'username' => 'root', | |
'password' => 'root', | |
'database' => 'test1', | |
'charset' => 'utf8', | |
), | |
array( | |
'driver' => 'mysql', | |
'host' => 'localhost', | |
'username' => 'root', | |
'password' => 'root', | |
'database' => 'test2', | |
'charset' => 'utf8', | |
), | |
); | |
..::init($options); | |
$options = array( | |
'driver' => 'mysql', | |
'host' => 'localhost', | |
'username' => 'root', | |
'password' => 'root', | |
'database' => 'test1', | |
'charset' => 'utf8', | |
); | |
..::init($options); |
co použít reset() a is_array(current())?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lze nějak lépe zjišťovat rozměr pole, abych mohl funkci předat jak array(), tak i array(array(), array(), ...) a nemusel použít break ve foreach a zároveň se nejednalo o psaní další funkce, která by činnost jen zpomalovala? Díky za pomoc.