| verzia 1.17, 2002/02/12 23:18:54 |
verzia 1.18, 2002/02/14 12:11:05 |
|
|
| * - sessions implemented |
* - sessions implemented |
| * - various bugfixes and SQL improvements |
* - various bugfixes and SQL improvements |
| * 13/01/2002 - PEAR compliancy |
* 13/01/2002 - PEAR compliancy |
| |
* 12/02/2002 - raw logging support |
| |
* 14/02/2002 - fixed posible SQL insert statement failure when parraler |
| |
* connection inserts the same record as we |
| */ |
*/ |
| |
|
| /* |
/* |
| Riadok 642 class Web_Log { |
|
| Riadok 645 class Web_Log { |
|
| |
|
| $this->_checkDB(); |
$this->_checkDB(); |
| |
|
| $query = "select id from $table" |
for ($i = 0; $i < 2; $i++) { |
| ." where value = substring('" . addslashes($value) . "', 1, 255)" |
$query = "select id from $table" |
| ." limit 1"; // TODO: 'limit' seems to be MySQL dependent, or no? |
." where value = substring('" .addslashes($value). "', 1, 255)" |
| $id = $this->_db->getOne($query); |
." limit 1"; // TODO: 'limit' is MySQL dependent, or no? |
| |
$id = $this->_db->getOne($query); |
| if (DB::isError($id)) |
|
| $this->_error($id->getMessage()); |
if (DB::isError($id)) |
| |
$this->_error($id->getMessage()); |
| if ($id) |
|
| return $id; |
if ($id) |
| |
return $id; |
| /* Important note: |
|
| |
/* Important note: |
| We cannot count id before insert (for example with: select |
|
| max(id) from $table) because there can be also another connection |
We cannot count id before insert (for example with: select |
| to the same database. It queries the same maximal id and insert |
max(id) from $table) because there can be also another connection |
| appropriate record into table. And our insert will fail. |
to the same database. It queries the same maximal id and insert |
| */ |
appropriate record into table. And our insert will fail. |
| |
*/ |
| $query = "insert into $table (id, value)" |
|
| ." values (0, '" . addslashes($value) . "')"; |
$query = "insert into $table (id, value)" |
| $result = $this->_db->query($query); |
." values (0, '" . addslashes($value) . "')"; |
| |
$result = $this->_db->query($query); |
| if (DB::isError($result)) |
|
| $this->_error($result->getMessage()); |
/* |
| |
* There is a possibility of insert failure. Paraller connection |
| |
* could insert the same record into table as we. So if it was |
| |
* the first fail, go once again and check if it is record already |
| |
* inserted. If it will fails again, than raise error. |
| |
*/ |
| |
|
| |
if (DB::isError($result)) { |
| |
if ($i > 0) |
| |
$this->_error($result->getMessage()); |
| |
} |
| |
else { |
| |
break; |
| |
} |
| |
} |
| |
|
| $query = "select last_insert_id()"; // TODO: lst_insert_id() is MySQL dependent? |
// TODO: last_insert_id() is MySQL dependent? |
| |
$query = "select last_insert_id()"; |
| $id = $this->_db->getOne($query); |
$id = $this->_db->getOne($query); |
| |
|
| if (DB::isError($id)) |
if (DB::isError($id)) |