MySQL: Wieder mal ein LOCK Problem

Mik3e

Erfahrenes Mitglied
Hallo!

Ich stehe wieder mal vor einem LOCK Problem.
Es geht schlicht um eine Tabelle, in der ein Datensatz kopiert werden soll.
Da auf der Kopie anschließend noch Updates ausgeführt werden, muss die Tabelle bis nach dem Update-Vorgang gelockt werden.

Das ganze sieht so aus:
PHP:
// TABELLEN LOCKEN
		$sql = ' LOCK TABLES tbl_ticketlayout WRITE ';
		$this->_db->query($sql);
				
		// KOPIEREN DES DATENSATZES
		$sql = ' INSERT INTO '
			. ' `tbl_ticketlayout` '
			. ' (`fk_veranstalter_id`, `fk_ticketlayout_typ_id`, `fk_ticketlayout_aufloesung_id`, `ticketlayout_breite_mm`, `ticketlayout_hoehe_mm`) '
			. ' SELECT '
			. ' `fk_veranstalter_id`, `fk_ticketlayout_typ_id`, `fk_ticketlayout_aufloesung_id`, `ticketlayout_breite_mm`, `ticketlayout_hoehe_mm` '
			. ' FROM '
			. ' `tbl_ticketlayout` '
			. ' WHERE '
			. ' `pk_ticketlayout_id`=\''.$ticketlayout_id.'\'';
		$this->_db->query($sql);

// TABELLEN FREIGEBEN
		$sql = ' UNLOCK TABLES ';
        $this->_db->query($sql);

Das ganze funktioniert nur leider nicht. Ohne LOCK geht es problemlos.
Und ich weiß nicht, wo mein Fehler beim Locking liegen könnte (es gibt keine Aliases, WRITE muss auch stimmen).

Vielleicht habt ihr eine Idee,
LG
Mike
 
Zurück