EDB
[ class tree: EDB ] [ index: EDB ] [ all elements ]

Class: EDB

Source Location: /EDB/edb.php

Class Overview

EDB_Common
   |
   --EDB

확장 DB 추상화 layer


Methods


Inherited Variables

Inherited Methods

Class: EDB_Common

EDB_Common::bind_param()
replace bind parameters to parameter's value
EDB_Common::check_param()
Check parameter type and parameters
EDB_Common::file_exists()
Checks whether a file or directory exists
EDB_Common::get_param_number()
Get number of query parameters
EDB_Common::switch_freemark()
Change free marking

Class Details

[line 60]
확장 DB 추상화 layer

이 패키지는 다음의 DB 추상화 계층을 제공한다.

  • CUBRID
  • MSSQL
  • MYSQL
  • MYSQLi
  • PostgreSQL
  • SQLite2
  • SQLite3
  • SQLRelay




[ Top ]


Class Methods


constructor __construct [line 89]

resource __construct( string $host,...)

EDB 클래스 초기화

지원되는 추상화 계층으로는 cubrid, mysql, mysqli, pgsql, sqlite2, sqlite3를 지원한다.




Tags:

return:  지정한 DB extension resource
see:  EDB_SQLITE2::__construct()
see:  EDB_SQLITE3::__construct()
see:  EDB_MYSQLI::__construct()
see:  EDB_MYSQL::__construct()
see:  EDB_MSSQL::__construct()
see:  EDB_PGSQL::__construct()
see:  EDB_CUBRID::__construct()
access:  public


Parameters:

string   $host,...   데이터베이스 호스트

[ Top ]

method close [line 421]

void close( )

DB 핸들을 종료한다.

기본적으로 EDB는 페이지가 종료될 때 각 DB class의 __destruct에서 close를 하기 때문에 따로 호출을 할 필요가 없다.

크드 중간에서 close를 명시적으로 해야할 필요가 있을 경우에 사용을 하면 된디.




Tags:

access:  public


[ Top ]

method escape [line 189]

string escape( string $buf, [string $type = 's'])

SQL 문에 사용이 되어지는 특수 문자를 에스케이프 시킨다.

DB API에서 지원을 할 경우 해당 API의 escape api를 사용하며, 지원하지 않을 경우, addslashes를 사용한다.

SQLRELAY와 PGSQL의 경우 원 문자열을 그대로 반환한다. SQL RELAY의 경우 해당 DB의 escape function을 이용해야 하며, PGSQL의 경우 PGSQL에서 지원 하는 data type의 escape function을 사용하도록 한다.

권고사항! 이 함수를 사용해야 하는 경우라면, 이 함수를 사용하는것 보다 bind query 를 사용하는 것을 권장한다!




Tags:

access:  public


Parameters:

string   $buf   escape 되어질 원본 문자열
string   $type   (optional) escape 형식. 이 파라미터는 PGSQL에서만 사용된다.
  • i - identifier
  • b - bytea
  • s - string (기본값)
  • u - unescape bytea

[ Top ]

method exqueried [line 120]

array exqueried( )

현재 세션에서 실행된 쿼리 목록을 반환



Tags:

return:  실행 쿼리 목록을 배열로 반환.
access:  public


[ Top ]

method fetch [line 299]

stdClass|false fetch( [boolean $free = false])

associative 개체로 result row를 가져온다.



Tags:

return:  result row로 가져온 object. result row가 0일 경우 false를 반환한다.
access:  public


Parameters:

boolean   $free   (optional) fetch 수행 후 result를 free한다. (기본값: false) EDB >= 2.0.3

[ Top ]

method fetch_all [line 318]

array fetch_all( [boolean $free = true])

모든 result row를 associative object 배열로 반환한다.

fetch_all method는 fetch를 수행후 result rows를 free한다. 만약 free하고 싶지 않다면, 첫번째 aurgument값으로 false를 지정하도록 한다.




Tags:

return:  associative object 배열. result row가 0일 경우 빈 배열을 반환한다.
access:  public


Parameters:

boolean   $free   (optional) fetch 수행후 result를 free 한다. (기본값: true)

[ Top ]

method field_name [line 331]

string field_name( integer $index)

지정한 n번째의 컬럼 이름을 반환한다.



Tags:

access:  public


Parameters:

integer   $index   0부터 시작하는 컬럼 인덱스 번호

[ Top ]

method field_type [line 350]

string field_type( integer $index, [string $table = ''])

지정한 n번째의 컬럼 유형을 반환한다.

sqlite3의 경우 null을 제외하고는 빈 값을 반환하므로, EDB package에서는 unknown, maybe libsqlite3 bug?로 반환한다.




Tags:

return:  db engine에 따라 자료형이 다르다.
access:  public


Parameters:

integer   $index   0부터 시작하는 컬럼 인덱스 번호
string   $table   (optional) table 이름. sqlite2 engine에서만 지정한다.

[ Top ]

method free_result [line 376]

boolean free_result( )

주어진 문장 핸들에 대하여 메모리에 저장된 결과를 해제.

query mehtod가 호출이 되면, fetch 결과가 있던 없던, 무조건 이 method가 호출이 되어져야 한다.




Tags:

return:  sqlite, sqlite3, mysqli는 항상 true를 반환한다.
access:  public


[ Top ]

method get_charset [line 139]

string get_charset( )

Get current db charset.

현재의 db 문자셋을 가져온다.

이 method는 실 DBMS에 의하여 제약이 있다. mysql, sqlite3는 Unsupport를 반환한다.




Tags:

return:  현재 문자셋 이름 반환
access:  public


[ Top ]

method lastId [line 265]

integer lastId( )

마지막 실행한 쿼리에서 자동으로 생성된 키값(Primary Key) 또는 row OID 값을 반환한다.



Tags:

return:  row OID를 반환. 이전 query가 새로운 row id를 생성하지 않았을 경우나 실행 실패시에 0을 반환한다.
     - cubrid   : returns inserted value of AUTO_INCREMENT column
     - mssql    : returns inserted row OID
     - mysql    : returns inserted value of Primary Key
     - mysqli   : returns inserted value of Primary key
     - pgsql    : returns inserted row OID
     - sqlite2  : returns inserted row OID
     - sqlite3  : returns inserted row OID
     - sqlrelay : returns inserted value of autoincrement column
since:  2.0.4
access:  public


[ Top ]

method num_fields [line 362]

integer num_fields( )

해당 row의 field 수를 반환한다.



Tags:

access:  public


[ Top ]

method query [line 239]

integer|false query( string $query, string $type, mixed $param1, mixed $param2,...)

데이터베이스상에서 쿼리를 실행한다.

blob 데이터 (binary data) 입력시에는 가능한 bind query를 사용하는 것을 권장한다.

fetch가 필요 없는 query를 수행하더라고, 수행 후에는 free_result method를 호출해 주어야 한다.




Tags:

return:  실제 적용된 row 수
access:  public


Parameters:

string   $query   실행할 쿼리
string   $type  

(optional) bind 파라미터 형식

bind parameter 형식은 각 DB 엔진의 영향을 받지 않으며 EDB 패키지가 직접 테스트를 하고, engine으로 전달이 되지는 않는다.

단, blob과 clob의 경우 해당 DB API에서 관련 API를 제공을 할 경우에는 해댱 API를 이용 하게 된다.

EDB 패키지에서 지원하는 형식은 다음과 같다.

  • b blob
  • c clob
  • i integer
  • f float, double
  • n null
  • 검사를 하지 않고 bypass.
  • bcifn 외의 형식은 모두 s로 지정을 하면 무난하게 통과된다.
blob와 clob type으로 지정했을 경우 bind parameter 값은 data 멤버와 len 멤버를 가진 object로 주어져야 한다.

  1.          $param = (object) array ('data' => 'value''len' => 'value');

또한, blob 데이터 insert/update 시에 bind query를 사용하면 binary data를 escape 할 필요가 없다.

mixed   $param1   (optional) 첫번째 bind 파라미터 값
mixed   $param2,...   (optional) 두번째 bind 파라미터 값

[ Top ]

method seek [line 284]

boolean seek( integer $offset)

result row 포인터를 이동한다.

sqlite/sqlite3의 경우 무조건 처음으로 돌아가서 원하는 offset까지 이동을 하므로 속도 저하가 발생할 수 있다.

offset이 row num보다 클경우에는 마지막 row로 이동을 한다.




Tags:

access:  public


Parameters:

integer   $offset   0부터 전체 반환 row수 - 1 까지의 범위

[ Top ]

method set_charset [line 158]

bool set_charset( [string $char = 'utf8'])

Set database charset.

DB 문자셋을 설정/변경 한다.

이 method는 실 DB의 영향을 받는다.

mysql과 mysqli만 지원을 하며, 나머지는 모두 아무런 동작 없이 항상 true만 반환한다.




Tags:

access:  public


Parameters:

string   $char   DB가 지원하는 문자셋 이름

[ Top ]

method transaction_end [line 403]

void transaction_end( [bool $v = true])

DB transaction을 종료한다.



Tags:

since:  2.0.5
access:  public


Parameters:

bool   $v   false일경우 rollback을 수행한다.

[ Top ]

method transaction_start [line 389]

void transaction_start( )

DB transaction을 시작한다.



Tags:

since:  2.0.5
access:  public


[ Top ]


Documentation generated on Tue, 14 May 2019 01:59:47 +0900 by phpDocumentor 1.4.4