개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.05.15 23:45

PDO SQLite Aggregate 함수 관련 질문

목록
  • RESTful도령 1일 전 2025.05.15 23:45
  • 4
    1
PdoSqlite::createAggregate를 사용하여 사용자 정의 Aggregate 함수를 만들 수 있나요?
그리고 Aggregate 함수가 실제로 DB에 저장되는 방식은 무엇인가요?

    댓글목록

    profile_image
    나우호스팅  1일 전



    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

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 19,948건 / 15 페이지

검색

게시물 검색