Skip to main content

I'm going to develop an Android application that performs simple MySQL operations by invoking server-sided phpPHP scripts. PHP-MySQL communication is done by MySQLi extension. Each operation that I'd like to perform is in a separate phpPHP file, and in a separate class. There's an example of update.php:

class Database
{   
    public $connection;

    function __construct()
    {   
        if(!isset($_SESSION)){
            session_start();
        }
        $this->connection = new mysqli('localhost', $_SESSION['login'], $_SESSION['password'], 'Ubezpieczenia_OC');
        
        if($this->connection->connect_error) {
            doDatabaseConnectionError();
        } else {
            $this->connection->set_charset("utf8");
            
            if(!isset($_SESSION['tables_white_list']) || !isset($_SESSION['columns_white_list'])){
                $_SESSION['tables_white_list'] = array('klienci', 'polisy_oc', 'parametry_oc', 'modele_samochodow', 'marki_samochodow');
                $_SESSION['columns_white_list'] = getTablesColumns($this->connection);
            }
        }
    }
}

I'm going to develop an Android application that performs simple MySQL operations by invoking server-sided php scripts. PHP-MySQL communication is done by MySQLi extension. Each operation that I'd like to perform is in separate php file, and in separate class. There's an example of update.php:

class Database
{   
    public $connection;

    function __construct()
    {   
        if(!isset($_SESSION)){
            session_start();
        }
        $this->connection = new mysqli('localhost', $_SESSION['login'], $_SESSION['password'], 'Ubezpieczenia_OC');
        
        if($this->connection->connect_error) {
            doDatabaseConnectionError();
        } else {
            $this->connection->set_charset("utf8");
            
            if(!isset($_SESSION['tables_white_list']) || !isset($_SESSION['columns_white_list'])){
                $_SESSION['tables_white_list'] = array('klienci', 'polisy_oc', 'parametry_oc', 'modele_samochodow', 'marki_samochodow');
                $_SESSION['columns_white_list'] = getTablesColumns($this->connection);
            }
        }
}
}

I'm going to develop an Android application that performs simple MySQL operations by invoking server-sided PHP scripts. PHP-MySQL communication is done by MySQLi extension. Each operation that I'd like to perform is in a separate PHP file, and in a separate class. There's an example of update.php:

class Database
{   
    public $connection;

    function __construct()
    {   
        if(!isset($_SESSION)){
            session_start();
        }
        $this->connection = new mysqli('localhost', $_SESSION['login'], $_SESSION['password'], 'Ubezpieczenia_OC');
        
        if($this->connection->connect_error) {
            doDatabaseConnectionError();
        } else {
            $this->connection->set_charset("utf8");
            
            if(!isset($_SESSION['tables_white_list']) || !isset($_SESSION['columns_white_list'])){
                $_SESSION['tables_white_list'] = array('klienci', 'polisy_oc', 'parametry_oc', 'modele_samochodow', 'marki_samochodow');
                $_SESSION['columns_white_list'] = getTablesColumns($this->connection);
            }
        }
    }
}
Shortened title
Link
Phrancis
  • 20.5k
  • 6
  • 70
  • 155

MySQL database operations byupdate with PHP; sharing connection between scripts/classes, MySQLi prepared statement in loop

edited title
Link
apex39
  • 322
  • 3
  • 10

MySQL database operations by PHP; sharing connection between scripts/classes, MySQLi prepared statement in loop

Source Link
apex39
  • 322
  • 3
  • 10
Loading