
SwooleTable::current 함수는 현재 트랜잭션의 데이터를 읽어올 수 있습니다.
이 함수는 현재 트랜잭션의 데이터를 읽어오기 때문에, 트랜잭션을 시작한 후에 호출해야 합니다.
트랜잭션을 시작하는 방법은 다음과 같습니다.
#hostingforum.kr
php
$table = new SwooleTable(100, 'uint', ['name', 'age']);
$table->column('name', ['length' => 50]);
$table->column('age', ['default' => 0]);
$table->begin();
$table->set(1, ['name' => 'John', 'age' => 30]);
$table->set(2, ['name' => 'Jane', 'age' => 25]);
$table->commit();
트랜잭션을 시작한 후에, SwooleTable::current 함수를 호출하여 현재 트랜잭션의 데이터를 읽어올 수 있습니다.
#hostingforum.kr
php
$currentData = $table->current();
print_r($currentData);
이 코드는 현재 트랜잭션의 데이터를 읽어와 출력합니다.
만약 트랜잭션을 롤백한다면, SwooleTable::current 함수를 호출하여 현재 트랜잭션의 데이터를 읽어올 수 없습니다.
#hostingforum.kr
php
$table->begin();
$table->set(1, ['name' => 'John', 'age' => 30]);
$table->set(2, ['name' => 'Jane', 'age' => 25]);
$table->rollback();
$currentData = $table->current();
print_r($currentData); // null
이 코드는 트랜잭션을 롤백한 후에, SwooleTable::current 함수를 호출하여 현재 트랜잭션의 데이터를 읽어오려고 하지만 null을 반환합니다.
따라서, 트랜잭션을 롤백한 후에 SwooleTable::current 함수를 호출하는 것은 의미가 없습니다.
2025-07-28 04:02