первые наброски
class CElmtBase
{
protected $SQLDefaultQuery = '';
protected $SQLCurrentQuery = '';
protected $SQLUpdateQuery = '';
protected $SQLDeleteQuery = '';
protected $SQLInsertQuery = '';
protected $TableName = '';
protected $DatabaseName = '';
protected $PrimaryKeyName = '';
// set's
public function setSQLDefaultQuery($Value) {
$this->SQLDefaultQuery = $Value;
}
public function setSQLCurrentQuery($Value) {
$this->SQLCurrentQuery = $Value;
}
public function setSQLUpdateQuery($Value) {
$this->SQLUpdateQuery = $Value;
}
public function setSQLDeleteQuery($Value) {
$this->SQLDeleteQuery = $Value;
}
public function setSQLInsertQuery($Value) {
$this->SQLInsertQuery = $Value;
}
public function setTableName($Value) {
$this->TableName = $Value;
}
public function setDatabaseName($Value) {
$this->DatabaseName = $Value;
}
public function setPrimaryKeyName($Value) {
$this->PrimaryKeyName = $Value;
}
// get's
public function getSQLDefaultQuery() {
return $this->SQLDefaultQuery;
}
public function getSQLCurrentQuery() {
return $this->SQLCurrentQuery;
}
public function getSQLUpdateQuery() {
return $this->SQLUpdateQuery;
}
public function getSQLDeleteQuery() {
return $this->SQLDeleteQuery;
}
public function getSQLInsertQuery() {
return $this->SQLInsertQuery;
}
public function getTableName() {
return $this->TableName;
}
public function getDatabaseName() {
return $this->DatabaseName;
}
public function getPrimaryKeyName() {
return $this->PrimaryKeyName;
}
};
class ecs extends CElmtBase
{
//
private $server;
private $username;
private $password;
private $database;
private $charset; // default
//
private $instance;
private function InitVariables($server, $username, $password, $database, $charset)
{
$this->server = $server;
$this->username = $username;
$this->password = $password;
$this->database = $database;
$this->charset = $charset;
}
private function InitInstance() {
$this->instance = mysqli_init();
}
private function InitSession()
{
mysqli_real_connect($this->instance, $this->server, $this->username, $this->password, $this->database);
mysqli_set_charset($this->instance, $this->charset);
}
public function setCharset($charset) {
mysqli_set_charset($this->instance, $charset);
}
public function setDatabaseName($Database) {
mysqli_select_db($this->instance, $Database);
}
// Constructor
public function __construct($server, $username = '', $password = '', $database = '', $charset = 'utf8')
{
$this->InitVariables($server, $username, $password, $database, $charset);
$this->InitInstance();
$this->InitSession();
}
//Destructor
function __destruct() {
mysqli_close($this->instance);
}
}
$var = new ecs('localhost');
Можно ли как то сохранить состояние объекта $var = new ecs('localhost'); после обновления страницы, что бы его каждый раз не создавать ?
ecs - Внешняя система связи.