GOModel mysql database connection

Connect to mysql database

Connect to mysql database using connect function. You need to pass host/servername, username, password, database-name. Optionally, you can pass charset.

Function Defination

  
                                void function connect($hostName, $userName, $password, $databaseName, $dbType = "mysql", $charset = "utf8");
                                

Parameters Details

Details Type Example
$userName - username of database to connect with string e.g. "root"
$password - password string e.g. ""
$databaseName - database name string e.g. "empDB"
$dbType - type of db string e.g. "mysql"(default), sqlite, pgsql
$charset - character set string e.g. "utf8"

Examples

  
                                $GOModel = new GOModel(); //create object of the GOModel class
                                $GOModel->connect("localhost", "root", "", "database");//connect to database
                            

More Examples

 
                                $GOModel->connect("localhost", "root", "", "database" ,"mysql","utf8");//connect to database                                
                            

Result/Output

Mysql Database will be connected

Debug

Option Details Example
print_r($GOModel->error) Print errors (if any)