MySQLm Docs - Connecting - back

How to Connect?


<?php
    # The first and easy way to connect to an MySQL Server is to use auto-connect:
?>

<?php
    # Including MySQLm [See https://github.com/AtjonTV/MySQLm/wiki/1.-Getting-Started or https://atjontv.github.io/MySQLm/starting.html]
    include 'https://raw.githubusercontent.com/AtjonTV/MySQLm/dev-1.5/src/MySQLm.php';
    // MySQLm::__construct takes 5 arguments: server, port, user, password, database 
    $msql = new MySQLm("database-server.com", 3306, "myusername", "userspassword", "databasename", "charset");
    $msql->dispose("acc", "x"); // Closing the connection and destroying the Object internaly
?>


<?php
    # The second and also easy way to connect, is using connect();
?>

<?php
    # Including MySQLm [See https://github.com/AtjonTV/MySQLm/wiki/1.-Getting-Started or https://atjontv.github.io/MySQLm/starting.html]
    include 'https://raw.githubusercontent.com/AtjonTV/MySQLm/dev-1.5/src/MySQLm.php';
    // MySQLm::__construct can be used without any real arguments
    $msql = new MySQLm("", "", "", "", "", "");
    // MySQLm::connect takes the same 5 arguments as __construct: server, port, user, password, database
    $msql->connect("database-server.com", 3306, "myusername", "userspassword", "databasename", "charset");
    $msql->dispose("acc", "x"); // Closing the connection and destroying the Object internaly
?>


<?php
    # The third way is to connect without a given database and manualy use one
?>

<?php
    # Including MySQLm [See https://github.com/AtjonTV/MySQLm/wiki/1.-Getting-Started or https://atjontv.github.io/MySQLm/starting.html]
    include 'https://raw.githubusercontent.com/AtjonTV/MySQLm/dev-1.5/src/MySQLm.php';
    // MySQLm::__construct can be used without any real arguments
    $msql = new MySQLm("", "", "", "", "", "");
    // MySQLm::connect_ndb only takes the same 4 arguments: server, port, user, password
    $msql->connect_ndb("database-server.com", 3306, "myusername", "userspassword", "charset");
    // Manualy running the USE command
    $msql->executeUse("USE databasename;");
    $msql->dispose("acc", "x"); // Closing the connection and destroying the Object internaly
?>