Since the library is using lazy connection (it is not actually connecting to the database until the first
query is executed), the object representing the connection to the MySQL server is not available at this time. If
you need it, use the {@link get_link()} method.
If you need the connection to the database to be made right away, set the connect argument to TRUE.
create the database object
$db = new Zebra_Database();
notice that we're not doing any error checking. errors will be shown in the debugging console
$db->connect('host', 'username', 'password', 'database');
code goes here
show the debugging console (if enabled)
$db->show_debug_console();
public connect ( string $host, string $user, string $password, string $database, string $port = '', string $socket = '', boolean $connect = false ) : void | ||
$host | string | The address of the MySQL server to connect to (i.e. localhost). Prepending host by p: opens a persistent connection. @param string $user The user name used for authentication when connecting to the MySQL server. @param string $password The password used for authentication when connecting to the MySQL server. @param string $database The database to be selected after the connection is established. @param string $port (Optional) The port number to attempt to connect to the MySQL server. Leave as empty string to use the default as returned by ini_get("mysqli.default_port"). @param string $socket (Optional) The socket or named pipe that should be used. Leave as empty string to use the default as returned by ini_get("mysqli.default_socket"). Specifying the socket parameter will not explicitly determine the type of connection to be used when connecting to the MySQL server. How the connection is made to the MySQL database is determined by the host argument. @param boolean $connect (Optional) Setting this argument to TRUE will force the library to connect to the database right away instead of using a "lazy connection" where the actual connection to the database will be made when the first query is run. Default is FALSE. @return void |
$user | string | |
$password | string | |
$database | string | |
$port | string | |
$socket | string | |
$connect | boolean | |
return | void |