
PDO SQLite에서 사용자 정의 Aggregate 함수를 만들기 위해서는 PdoSqlite::createAggregate 메소드를 사용할 수 있습니다.
#hostingforum.kr
php
$stmt = $pdo->prepare("CREATE AGGREGATE my_func(STRING, INTEGER)");
$stmt->execute();
$stmt = $pdo->prepare("CREATE FUNCTION my_func(STRING, INTEGER) RETURNS STRING");
$stmt->execute();
$stmt = $pdo->prepare("CREATE AGGREGATE my_func(STRING, INTEGER) USING my_func");
$stmt->execute();
Aggregate 함수는 실제로 DB에 저장되지 않고, SQLite가 실행되는 동안에만 사용됩니다.
Aggregate 함수는 SQLite가 데이터를 처리하는 동안에만 사용되기 때문에, Aggregate 함수가 실제로 DB에 저장되는 방식은 없습니다.
Aggregate 함수는 SQLite의 메모리에서만 사용되기 때문에, Aggregate 함수를 사용할 때는 SQLite가 실행되는 동안에만 사용할 수 있습니다.
Aggregate 함수를 사용할 때는 Aggregate 함수를 정의한 후에, Aggregate 함수를 사용할 수 있습니다.
#hostingforum.kr
php
$stmt = $pdo->prepare("SELECT my_func('hello', 10) AS result");
$stmt->execute();
$result = $stmt->fetchColumn();
print($result); // 'hello10'
2025-05-15 23:46