
TableInsert::values는 데이터베이스에 여러 행의 데이터를 INSERT하는 데 사용되는 메서드입니다.
TableInsert::values를 사용하여 여러 행의 데이터를 INSERT할 수 있습니다. 예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$tableInsert = new TableInsert();
$tableInsert->values([
['name' => 'John', 'age' => 25],
['name' => 'Jane', 'age' => 30],
]);
$tableInsert->execute();
TableInsert::values의 경우, 데이터 타입을 지정할 필요가 없습니다. 데이터베이스가 자동으로 데이터 타입을 인식합니다. 하지만, 데이터 타입을 지정할 경우 더 안전하고 효율적인 INSERT 연산을 수행할 수 있습니다.
#hostingforum.kr
php
$tableInsert = new TableInsert();
$tableInsert->values([
['name' => 'John', 'age' => 25],
['name' => 'Jane', 'age' => 30],
], [
'name' => 'varchar(255)',
'age' => 'int',
]);
$tableInsert->execute();
TableInsert::values를 사용하여 NULL 값을 INSERT할 수 있습니다. NULL 값을 INSERT할 경우, 데이터베이스가 자동으로 NULL 값을 인식합니다.
#hostingforum.kr
php
$tableInsert = new TableInsert();
$tableInsert->values([
['name' => 'John', 'age' => 25, 'email' => null],
]);
$tableInsert->execute();
TableInsert::values의 경우, WHERE 조건을 지정할 수 없습니다. WHERE 조건을 지정하려면 UPDATE 또는 DELETE 메서드를 사용해야 합니다.
#hostingforum.kr
php
$tableInsert = new TableInsert();
$tableInsert->values([
['name' => 'John', 'age' => 25],
]);
$tableInsert->where('age > 20');
$tableInsert->execute();
위의 예제는 UPDATE 연산을 수행하는 예제입니다. WHERE 조건을 지정하려면 UPDATE 또는 DELETE 메서드를 사용해야 합니다.
2025-04-06 21:53