Source for file LC_Page_Admin_Contents_CsvSql.php
Documentation is available at LC_Page_Admin_Contents_CsvSql.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(CLASS_PATH .
"pages/LC_Page.php");
* CSV 出力項目設定(高度な設定)のページクラス.
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_Contents_CsvSql.php 17675 2008-11-01 06:44:55Z Seasoft $
$this->tpl_subnavi =
'contents/subnavi.tpl';
$this->tpl_subno =
'csv';
$this->tpl_subno_csv =
'csv_sql';
$this->tpl_subtitle =
'CSV出力設定';
if (!isset
($_POST['mode'])) $_POST['mode'] =
"";
if (!isset
($_POST['sql_id'])) $_POST['sql_id'] =
"";
if (!isset
($_GET['sql_id'])) $_GET['sql_id'] =
"";
if (!isset
($_POST['selectTable'])) $_POST['selectTable'] =
"";
if ($_POST['sql_id'] !=
"") {
$sql_id =
$_POST['sql_id'];
}elseif($_GET['sql_id'] !=
""){
$sql_id =
$_GET['sql_id'];
if (count($this->arrErr) <=
0){
$sql =
"SELECT \n" .
$_POST['csv_sql']; // FIXME
$errMsg =
$objErrMsg->message .
"\n" .
$objErrMsg->userinfo;
$this->sqlerr = isset
($errMsg) ?
$errMsg :
"" ;
$this->objView =
$objView;
$objView->assignobj($this);
$objView->display('contents/csv_sql_view.tpl');
$arrCsvData =
$this->lfGetSqlList(" WHERE sql_id = ?", array($_POST['csv_output_id']));
$arrCsvOutputData =
$objQuery->getall("SELECT " .
$arrCsvData[0]['csv_sql']);
if (count($arrCsvOutputData) >
0) {
foreach($arrKey as $data) {
if ($i !=
0) $header .=
", ";
$data =
SC_Utils_Ex::getCSVData($arrCsvOutputData, $arrKey);
// mode が confirm 以外のときは完了メッセージは出力しない
if ($mode !=
"confirm" and $mode !=
"csv_output") {
$arrSqlData =
$this->lfGetSqlList(" WHERE sql_id = ?", array($sql_id));
$arrTableList =
SC_Utils_Ex::sfSwapArray($arrTableList);
if ($_POST['selectTable'] ==
""){
$selectTable =
$arrTableList['table_name'][0];
$selectTable =
$_POST['selectTable'];
foreach ($arrTableList['description'] as $key =>
$val) {
$arrTableList['description'][$key] =
$arrTableList['table_name'][$key] .
":" .
$arrTableList['description'][$key];
foreach ($arrColList['description'] as $key =>
$val) {
$arrColList['description'][$key] =
$arrColList['column_name'][$key] .
":" .
$arrColList['description'][$key];
$arrDiff =
array_diff($objDbFactory->sfGetColumnList($selectTable), $arrColList["column_name"]);
$arrColList["column_name"] =
array_merge($arrColList["column_name"], $arrDiff);
$arrColList["description"] =
array_merge($arrColList["description"], $arrDiff);
$this->arrSqlList =
$arrSqlList; // SQL一覧
$this->arrTableList =
SC_Utils_Ex::sfarrCombine($arrTableList['table_name'], $arrTableList['description']); // テーブル一覧
$this->arrColList =
SC_Utils_Ex::sfarrCombine($arrColList['column_name'],$arrColList['description']); // カラム一覧
$this->selectTable =
$selectTable; // 選択されているテーブル
$this->sql_id =
$sql_id; // 選択されているSQL
$arrSqlData[0]['sql_name'] = isset
($_POST['sql_name']) ?
$_POST['sql_name'] :
"";
$arrSqlData[0]['csv_sql'] = isset
($_POST['csv_sql']) ?
$_POST['csv_sql'] :
"";
$this->arrSqlData =
$arrSqlData[0]; // 選択されているSQLデータ
$objView->assignobj($this);
$objView->display(MAIN_FRAME);
$arrRet =
array(); // 結果取得用
$sql .=
"SELECT table_name, description FROM dtb_table_comment WHERE column_name IS NULL ORDER BY table_name";
$arrRet =
$objQuery->getAll($sql);
* @param string $selectTable テーブル名
$arrRet =
array(); // 結果取得用
$sql .=
" SELECT column_name, description FROM dtb_table_comment WHERE table_name = ? AND column_name IS NOT NULL";
$arrRet =
$objQuery->getAll($sql, array($selectTable));
* @param string $where Where句
* @param array $arrData 絞り込みデータ
$arrRet =
array(); // 結果取得用
$sql .=
" ORDER BY sql_id ";
// データを引数で渡されている場合にはセットする
if (count($arrData) >
0) {
$arrRet =
$objQuery->getall($sql, $arrData);
$arrRet =
$objQuery->getall($sql);
$objErr->doFunc( array("名称", "sql_name"), array("EXIST_CHECK") );
$objErr->doFunc( array("SQL文", "csv_sql", "30000"), array("EXIST_CHECK", "MAX_LENGTH_CHECK") );
if ($objErr->arrErr['csv_sql'] ==
"") {
$objErr->arrErr["csv_sql"] =
"SQL文が不正です。SQL文を見直してください";
$sql =
"SELECT " .
$data['csv_sql'] .
" ";
$ret =
$objDbConn->conn->query($sql);
if ($objDbConn->conn->isError($ret)){
* @param integer $sql_id 更新するデータのSQL_ID
* @param array $arrData 更新データの配列
* @return integer $sql_id SQL_IDを返す
function lfUpdData($sql_id =
"", $arrData =
array()){
$objQuery =
new SC_Query(); // DB操作オブジェクト
$sql =
""; // データ取得SQL生成用
$arrRet =
array(); // データ取得用(更新判定)
$arrVal =
array(); // データ更新
// sql_id が指定されている場合にはUPDATE
$arrSqlData =
$this->lfGetSqlList(" WHERE sql_id = ?", array($sql_id));
if (count($arrSqlData) >
0) {
$sql =
"UPDATE dtb_csv_sql SET sql_name = ?, csv_sql = ?, update_date = now() WHERE sql_id = ? ";
$arrVal=
array($arrData['sql_name'], $arrData['csv_sql'], $sql_id);
$sql =
"INSERT INTO dtb_csv_sql (sql_name, csv_sql, create_date, update_date) values (?, ?, now(), now()) ";
$arrVal=
array($arrData['sql_name'], $arrData['csv_sql']);
$sql =
"INSERT INTO dtb_csv_sql (sql_name, csv_sql, create_date, update_date) values (?, ?, now(), now()) ";
$arrVal=
array($arrData['sql_name'], $arrData['csv_sql']);
$arrRet =
$objQuery->query($sql,$arrVal);
$arrNewData =
$this->lfGetSqlList(" ORDER BY create_date DESC");
$sql_id =
$arrNewData[0]['sql_id'];
* @param integer $sql_id 削除するデータのSQL_ID
* @return bool 実行結果 TRUE:成功 FALSE:失敗
$objQuery =
new SC_Query(); // DB操作オブジェクト
$sql =
""; // データ取得SQL生成用
$sql =
"DELETE FROM dtb_csv_sql WHERE sql_id = ? ";
$ret =
$objQuery->query($sql,array($sql_id));
Documentation generated on Tue, 28 Apr 2009 18:10:55 +0900 by phpDocumentor 1.4.2