개요
XE에는 데이터베이스-애그노스틱(database-agnostic) DB 추상 레이어가 있습니다. 이 말은 XE를 다양한 DBMS와 함께 사용할 수 있고 DBMS 간 전환도 쉽게 할 수 있다는 뜻입니다. XE는 MySQL, MS SQL, CUBRID, PostgreSQL, SQLite3, Firebird를 지원합니다.
이를 위해서 XE의 XML 스키마 언어(XML Schema Language)와 XML 쿼리 언어(XML Query Language)를 사용해서 전체 DB 스키마와 쿼리를 XML로 작성합니다.
다음은 XML 스키마 파일의 예제입니다.
# Excerpt from ./modules/member/schemas/member.xml
<table name="member">
<column name="member_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="user_id" type="varchar" size="80" notnull="notnull" unique="unique_user_id" />
<column name="find_account_question" type="number" size="11" />
<column name="allow_mailing" type="char" size="1" default="Y" notnull="notnull" index="idx_allow_mailing" />
<column name="limit_date" type="date" />
<column name="regdate" type="date" index="idx_regdate" />
<column name="description" type="text" />
<column name="list_order" type="number" size="11" notnull="notnull" index="idx_list_order" />
</table>
XE를 처음 설치할 때 포함된 모듈 중 테이블.xml이 있으면 자동으로 테이블이 생성됩니다. XE를 설치한 후 추가 모듈을 설치할 때 테이블.xml이 있다면, 관리자 화면에 모듈 설치 버튼이 나타납니다. XML 파일을 통해 이 테이블에 대한 쿼리를 생성할 수 있습니다.
#./modules/member/queries/getMemberInfo.xml
<query id="getMemberInfo" action="select">
<tables>
<table name="member" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="user_id" var="user_id" notnull="notnull" />
</conditions>
</query>
이 쿼리를 PHP에서 호출하는 코드는 다음과 같이 매우 간단합니다.
$args->user_id = $user_id;
$output = executeQuery('member.getMemberInfo', $args);