You cannot see this page without javascript.

test/test.php

<?php
 define('__ZBXE__', true);
 define('__XE__', true);
 require_once $_SERVER['DOCUMENT_ROOT'].'/config/config.inc.php';
 $oContext = &Context::getInstance();
 $oContext->init();
      $args->document_srl = 1608;
      $args->rateval = 1; //1점이상인 사람만 가져옴
      $output = executeQueryArray('widgets.star_rating.getStarRatedList', $args);

 echo print_r($output,true);

$oContext->close();

?>

 


widgets/star_rating/query/getStarList.xml

 

<query id="getDocumentStarRatedList" action="select">
    <tables>
        <table name="document_voted_log" />
    </tables>
    <columns>
        <column name="member_srl" />
        <column name="rateval" />
    </columns>
    <conditions>
        <condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" pipe="and" />
        <condition operation="more" column="rateval" var="rateval" filter="number" pipe="and" />
    </conditions>
</query>


 

위와 같이 test.php 파일과 getStarList.xml 이라는 파일을 생성하고 test.php를 실행하면 제대로 배열값이 표시됩니다.

 

 

*풀이하기

 

1. test.php파일에 config.inc.php 를 읽어 들이면

'config/func.inc.php' 파일을 함께 포함하게 되면 아래와 같이 func.in.php에 정의된 다양한 xe의 기본 함수를 사용할 수 있습니다.

 

    function executeQuery($query_id, $args = null) {
        $oDB = &DB::getInstance();
        return $oDB->executeQuery($query_id, $args);
    }


 

2. 단,  $oContext = &Context::getInstance(); 를 선언해 주어야 제대로 작동합니다.

 

*고민

  

xe의 모듈과 위젯의 query를 이용할 수 있다는 점은 좋지만

새로운 db query 문을 실행하기 위해서는 선택을 해야합니다.

특정 모듈의 query 폴더에 쿼리 내용의 xml 파일을 만들어 저장하여 executeQuery() 함수를 사용할 것인지

아니면  $oDB=&DB::getInstance(); 를 선언하 사용할 것인지를.

 

아래의 코드는 위와 비슷한 db값을 출력하는 내용입니다. 다른 점을 찾아보세요.

 

test/test2.php

 

<?php
 define('__ZBXE__', true);
 define('__XE__', true);
 require_once $_SERVER['DOCUMENT_ROOT'].'/config/config.inc.php';
 $oContext = &Context::getInstance();
 $oContext->init();

 $oDB = &DB::getInstance();

 

 //$args->document_srl = 1608;
 //$args->rateval = 1; //1점이상인 사람만 가져옴

$member_srl = 4;

$document_srl = 1608;
$tablename = 'db_document_voted_log';

 // 사용자가 투표한 적이 있는지 검사
 $result = $oDB->_query("select rateval from $tablename where member_srl='$member_srl' && document_srl='$document_srl'");
 $output = $oDB->_fetch($result); //배열 재구성


echo print_r($output,true);

$oContext->close();

?>

엮인글 :
List of Articles
번호 제목 글쓴이 날짜sort 조회 수

Linux LFS/TheEnd - 마무리

  • LynX
  • 2014-08-06
  • 조회 수 382

Linux LFS/Make Bootable System - LFS 시스템 부팅하기

  • LynX
  • 2014-08-06
  • 조회 수 445

Linux LFS/Bootscripts - 시스템 부트로더 설정하기 [8]

  • LynX
  • 2014-08-06
  • 조회 수 570

Linux LFS/Building - 빌드하기 [11]

  • LynX
  • 2014-08-06
  • 조회 수 2614

Linux LFS/Preparation - 준비

  • LynX
  • 2014-08-06
  • 조회 수 745

Linux LFS/Introduction - 소개 [8]

  • LynX
  • 2014-08-06
  • 조회 수 669

Linux LFS/Preface - 서문 [9]

  • LynX
  • 2014-08-06
  • 조회 수 1072

Linux Custom Kernel 컴파일링 & 설치하기 [8]

  • LynX
  • 2014-08-06
  • 조회 수 457

Linux PDO_MYSQL 설치 [8]

  • LynX
  • 2014-08-01
  • 조회 수 310

Linux sendmail, dovecot 설치 및 설정 [20]

  • LynX
  • 2014-08-01
  • 조회 수 2724

Linux rc.local 서비스 등록하기

  • LynX
  • 2014-07-22
  • 조회 수 505

Linux systemd unit 등록 옵션

  • LynX
  • 2014-07-22
  • 조회 수 20455

Linux 페도라17(centos7) 새로운 서비스 관리

  • LynX
  • 2014-07-20
  • 조회 수 570

Linux SSH 컴파일 설치

  • LynX
  • 2014-07-19
  • 조회 수 377

Xpress Engine XML 쿼리 대신 직접 mysql 사용하기

  • LynX
  • 2014-07-19
  • 조회 수 273

Xpress Engine XML 쿼리 대신 직접 mysql 사용하기

  • LynX
  • 2014-07-16
  • 조회 수 391

Linux 리눅스 기본 명령어

  • LynX
  • 2014-07-16
  • 조회 수 792

Xpress Engine xe 외부 php 파일에서 db 접근하기 executeQuery()

  • LynX
  • 2014-07-14
  • 조회 수 920

Xpress Engine xe 모든 변수값 출력해 보기

  • LynX
  • 2014-07-14
  • 조회 수 93754

Xpress Engine XE용 query xml 방식으로 일반 테이블도 접근 처리 하기

  • LynX
  • 2014-07-14
  • 조회 수 459

XE Login