57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
{
$this->flags = \SQLITE3_OPEN_READWRITE;
if ($create)
{
$this->flags |= \SQLITE3_OPEN_CREATE;
}
// Ne pas se connecter ici, on ne se connectera que quand une requête sera faite
}
public function close()
{
$this->db->close();
|
>
>
>
>
>
>
>
>
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
{
$this->flags = \SQLITE3_OPEN_READWRITE;
if ($create)
{
$this->flags |= \SQLITE3_OPEN_CREATE;
}
// Fermer toute transaction en cours à la fin du script
// pour éviter de locker la base
// ceci est utile notamment en cas d'erreur dans le script ou de
// max_execution_time
register_shutdown_function(function () {
DB::getInstance()->commit(true);
});
// Ne pas se connecter ici, on ne se connectera que quand une requête sera faite
}
public function close()
{
$this->db->close();
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
}
$this->transaction++;
return $this->transaction == 1 ? true : false;
}
public function commit()
{
if ($this->transaction == 1)
{
$this->connect();
$this->db->exec('END;');
}
if ($this->transaction > 0)
{
$this->transaction--;
}
return $this->transaction ? false : true;
}
|
|
|
>
<
|
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
}
$this->transaction++;
return $this->transaction == 1 ? true : false;
}
public function commit($force = false)
{
if ($force || $this->transaction == 1)
{
$this->connect();
$this->db->exec('END;');
$this->transaction = 0;
}
else if ($this->transaction > 1)
{
$this->transaction--;
}
return $this->transaction ? false : true;
}
|