function getField()
 {
     $value = $this->getParam('value');
     if (!$value) {
         return ' - ';
     }
     $key_field = $this->getParam('key_field');
     $values_field = $this->getParam('values_field');
     $lookup_table = $this->getParam('lookup_table');
     $external_link = $this->getParam('external_link');
     $db = DBMysql::getInstance();
     $query = " SELECT `{$values_field}` FROM `{$lookup_table}` ";
     $query .= " WHERE `{$key_field}` = '{$value}' ";
     $db->setQuery($query);
     $field = $db->getResult();
     if ($field === false) {
         $this->errors[] = $db->getError();
         return false;
     }
     if ($external_link) {
         $external_link = str_replace('*', $value, $external_link);
         $external_link = $this->getURLString($external_link);
         $field = '<a href="' . $external_link . '">' . $field . '</a>' . "\n";
     }
     return $field;
 }
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #3
0
 /**
  * 得到实例 
  * 
  * @access public
  * @return mixed
  */
 public static function getInstance()
 {
     $dbinfo = self::getDbInfo();
     switch ($dbinfo['type']) {
         default:
             return DBMysql::getInstance($dbinfo);
     }
 }
 function loadItems()
 {
     //		if ($this->items) {
     //			return true;
     //		}
     $this->items = array();
     $value = $this->getParam('value');
     $add_no_answer = $this->getParam('add_no_answer');
     $mode = $this->getParam('mode');
     if ($mode != 'list' && $add_no_answer || $mode == 'list' && !$value) {
         $this->items[0] = '&nbsp;-&nbsp;';
     }
     $lookup_table = $this->getParam('lookup_table');
     $key_field = $this->getParam('key_field');
     $values_field = $this->getParam('values_field');
     $filters = $this->getParam('filters');
     if (!$lookup_table || !$key_field || !$values_field) {
         $name = $this->getParam('name');
         $this->errors[] = "Some lookup table parameters not set. Field '{$name}' ";
         return false;
     }
     $db = DBMysql::getInstance();
     $query = " SELECT `{$key_field}`, `{$values_field}` FROM `{$lookup_table}` ";
     $where_params = array();
     if ($mode == 'list' && $value) {
         $where_params[] = " `{$key_field}` = '{$value}' ";
     }
     if ($filters && is_array($filters)) {
         foreach ($filters as $filter) {
             $where_params[] = " `{$filter['field']}` = '{$filter['value']}' ";
         }
     }
     if ($where_params) {
         $query .= " WHERE " . implode(' AND ', $where_params);
     }
     $db->setQuery($query);
     $result = $db->getArrays();
     if ($result === false) {
         $this->errors[] = $db->getError();
         return false;
     }
     if (!$result) {
         $this->items[0] = '&nbsp;-&nbsp;';
     } else {
         foreach ($result as $value) {
             $this->items[$value[$key_field]] = $value[$values_field];
         }
     }
     return true;
 }
예제 #5
0
 /**
  * 取得实例
  * 
  * @access public
  * @param mixed $dbinfo
  * @return mixed
  */
 public static function getInstance($dbinfo)
 {
     self::$dbinfo = $dbinfo;
     if (!self::$dbo instanceof self) {
         self::$conn = mysql_connect($dbinfo['host'], $dbinfo['user'], $dbinfo['password']);
         if (self::$conn === false) {
             trigger_error('<span style="color:red;border:red 1px solid;padding:0.5em;">无法连接数据库,请检查数据库连接参数!</span>', E_USER_ERROR);
             exit;
         }
         $charset = isset($dbinfo['charset']) ? $dbinfo['charset'] : 'utf8';
         mysql_query("set names '{$charset}'");
         mysql_select_db($dbinfo['name'], self::$conn);
         self::$dbo = new self();
     }
     return self::$dbo;
 }
예제 #6
0
 public function migrateProject($idProjectOld)
 {
     $result = $this->dbOld->select('projects', array('id' => $idProjectOld));
     $projectsOld = $this->dbOld->getAssocArrays($result);
     foreach ($projectsOld as $projectOld) {
         unset($projectOld['id']);
         // get next insertion point for project hierarchy
         $rgt = $this->getNextProjectRgt();
         $projectOld['lft'] = $rgt + 1;
         $projectOld['rgt'] = $rgt + 2;
         $idProjectNew = $this->dbNew->insert('projects', $projectOld);
         $this->projectsMapping[$idProjectOld] = $idProjectNew;
         echo "migrating old redmine {$idProjectOld} => to new redmine {$idProjectNew} <br>\n";
         $this->migrateVersions($idProjectOld);
         $this->migrateCategories($idProjectOld);
         $this->migrateIssues($idProjectOld);
         $this->migrateIssuesParents($idProjectOld);
         $this->migrateIssueRelations($idProjectOld);
         $this->migrateNews($idProjectOld);
         $this->migrateDocuments($idProjectOld);
         $this->migrateBoards($idProjectOld);
         $this->migrateTimeEntries($idProjectOld);
         $this->migrateModules($idProjectOld);
         $this->migrateWikis($idProjectOld);
         $this->migrateAttachments($idProjectOld);
         $this->migrateWatchers($idProjectOld);
     }
     echo 'projects: ' . count($this->projectsMapping) . " <br>\n";
     echo 'issues: ' . count($this->issuesMapping) . " <br>\n";
     echo 'issue parents: ' . count($this->issuesParentsMapping) . " <br>\n";
     echo 'issue relations: ' . count($this->issuesRelationsMapping) . " <br>\n";
     echo 'attachments: ' . $this->nbAt . " <br>\n";
     echo 'categories: ' . count($this->categoriesMapping) . " <br>\n";
     echo 'versions: ' . count($this->versionsMapping) . " <br>\n";
     echo 'news: ' . count($this->newsMapping) . " <br>\n";
     echo 'documents: ' . count($this->documentsMapping) . " <br>\n";
     echo 'journals: ' . count($this->journalsMapping) . " <br>\n";
     echo 'watchers: ' . count($this->watchersMapping) . " <br>\n";
     echo 'boards: ' . count($this->boardsMapping) . " <br>\n";
     echo 'messages: ' . count($this->messagesMapping) . " <br>\n";
     echo 'time entries: ' . count($this->timeEntriesMapping) . " <br>\n";
     echo 'modules enabled: ' . count($this->modulesMapping) . " <br>\n";
     echo 'wikis: ' . count($this->wikisMapping) . " <br>\n";
     echo 'wiki pages: ' . count($this->wikipagesMapping) . " <br>\n";
     echo 'wiki contents: ' . count($this->wikiContentsMapping) . " <br>\n";
     echo 'wiki content versions: ' . count($this->wikiContentVersionsMapping) . " <br>\n";
 }
 function getValue()
 {
     $value = (int) $this->getParam('value');
     $name = $this->getParam('name');
     $table = $this->getParam('table');
     if (!$table) {
         return 1;
     }
     if (!$value) {
         $db = DBMysql::getInstance();
         $query = "SELECT MAX(`{$name}`) + 1 FROM `{$table}` ";
         $db->setQuery($query);
         $value = $db->getResult();
         if (!$value) {
             return 1;
         }
     }
     return $value;
 }
 function beforeDelete()
 {
     $check_foreign_key = $this->getParam('check_foreign_key');
     $key_field_value = $this->getParam('key_field_value');
     //		$many_to_many_table = $this->getParam('many_to_many_table');
     if (!$check_foreign_key) {
         return true;
     }
     $db = DBMysql::getInstance();
     foreach ($check_foreign_key as $foreign_key) {
         if (empty($foreign_key['is_allow_delete'])) {
             continue;
         }
         $query = "\n\t\t\t\tDELETE FROM `{$foreign_key['table']}`\n\t\t\t\tWHERE `{$foreign_key['field']}` = '{$key_field_value}'\n\t\t\t";
         $db->setQuery($query);
         if (!$db->query()) {
             $this->errors[] = $db->getError();
             return false;
         }
     }
     return true;
 }
예제 #9
0
        if ($select == '') {
            return new Object(-1, "Invalid query");
        }
        $select = 'SELECT ' . $select;
        $from = $query->getFromString($with_values);
        if ($from == '') {
            return new Object(-1, "Invalid query");
        }
        $from = ' FROM ' . $from;
        $where = $query->getWhereString($with_values);
        if ($where != '') {
            $where = ' WHERE ' . $where;
        }
        $groupBy = $query->getGroupByString();
        if ($groupBy != '') {
            $groupBy = ' GROUP BY ' . $groupBy;
        }
        $orderBy = $query->getOrderByString();
        if ($orderBy != '') {
            $orderBy = ' ORDER BY ' . $orderBy;
        }
        $limit = $query->getLimitString();
        if ($limit != '') {
            $limit = sprintf(' LIMIT %d, %d', $start_count, $list_count);
        }
        return $select . ' ' . $from . ' ' . $where . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
    }
}
DBMysql::$isSupported = function_exists('mysql_connect');
/* End of file DBMysql.class.php */
/* Location: ./classes/db/DBMysql.class.php */
예제 #10
0
<?php

//$stime=microtime(true); //获取程序开始执行的时间
require_once 'db.php';
$db = new DBMysql();
$spread = $_POST["spread"];
//$name = '"arch", "block", "crypto", "drivers", "fs", "include", "init", "ipc", "kernel", "lib", "mm", "net", "security", "sound"';
$name = 'arch@block@crypto@drivers@fs@include@init@ipc@kernel@lib@mm@net@security@sound';
$matrix_str = '[[0, 0, 2, 328, 121, 66, 3, 0, 1828, 291, 234, 0, 0, 0],
        [36, 0, 0, 47, 76, 0, 0, 0, 474, 242, 177, 0, 0, 0],
        [79, 0, 0, 2, 62, 6, 0, 0, 107, 60, 70, 0, 0, 0],
        [2677, 295, 0, 0, 1267, 340, 1, 0, 9732, 2541, 2530, 871, 3, 0],
        [702, 96, 0, 34, 0, 59, 0, 0, 3578, 508, 1450, 557, 118, 0],
        [114, 0, 0, 7, 3, 0, 0, 0, 2089, 62, 54, 46, 0, 1],
        [67, 8, 0, 9, 121, 0, 0, 0, 149, 34, 34, 0, 2, 0],
        [37, 0, 0, 0, 75, 0, 0, 0, 181, 26, 56, 8, 33, 0],
        [595, 11, 0, 109, 623, 32, 4, 8, 0, 654, 911, 54, 104, 0],
        [98, 0, 0, 25, 6, 0, 0, 0, 163, 0, 118, 12, 0, 0],
        [322, 17, 0, 19, 218, 32, 0, 2, 1036, 265, 0, 0, 15, 0],
        [1105, 0, 26, 108, 616, 400, 0, 0, 6768, 1557, 1289, 0, 132, 0],
        [185, 0, 0, 4, 110, 7, 0, 0, 591, 181, 452, 45, 0, 0],
        [278, 0, 0, 60, 43, 2, 0, 0, 1403, 186, 455, 0, 0, 0]
    ]';
if ($spread == 'null') {
    echo $name . '#' . $matrix_str;
    return;
} else {
    $spread_arr = json_decode($spread);
}
//unset($spread_arr);//测试
//$a = array(2);
 function afterSave()
 {
     //		var_dump($this);exit;
     $value = $this->getParam('value');
     $table = $this->getParam('db_table');
     $file_size_field = $this->getParam('file_size_field');
     $is_size_in_human_readable_format = $this->getParam('is_size_in_human_readable_format');
     $upload_path = $this->getParam('upload_path');
     $key_field_name = $this->getParam('key_field');
     $key_field_value = $this->getParam('key_field_value');
     if (!$file_size_field || $value === false) {
         return true;
     }
     $fileSize = '';
     if ($value !== '') {
         $fileSize = filesize($upload_path . $value);
         if ($is_size_in_human_readable_format) {
             switch ($fileSize) {
                 case $fileSize < 1024:
                     $fileSize = $fileSize . 'B';
                     break;
                 case $fileSize >= 1024 && $fileSize < 1048576:
                     $fileSize = round($fileSize / 1024) . 'KB';
                     break;
                 case $fileSize >= 1048576 && $fileSize < 1073741824:
                     $fileSize = round($fileSize / 1048576) . 'MB';
             }
         }
     }
     $db = DBMysql::getInstance();
     $query = "\n\t\t\tUPDATE `{$table}`\n\t\t\tSET `{$file_size_field}` = '{$fileSize}'\n\t\t\tWHERE `{$key_field_name}` = '{$key_field_value}'\n\t\t";
     //		var_dump($query);exit;
     $db->setQuery($query);
     if (!$db->query()) {
         $this->errors[] = $db->getError();
         return false;
     }
     return true;
 }
예제 #12
0
 /**
  * Handle selectAct
  * In order to get a list of pages easily when selecting \n
  * it supports a method as navigation
  * @param Object $queryObject
  * @param resource $connection
  * @param boolean $with_values
  * @return Object
  */
 function _executeSelectAct($queryObject, $connection = null, $with_values = false)
 {
     if ($this->use_prepared_statements != 'Y') {
         return parent::_executeSelectAct($queryObject, $connection);
     }
     $this->param = $queryObject->getArguments();
     $result = parent::_executeSelectAct($queryObject, $connection, $with_values);
     unset($this->param);
     return $result;
 }
예제 #13
0
 function getOldParserQuery($outputString)
 {
     $output = eval($outputString);
     if (is_a($output, 'Object')) {
         if (!$output->toBool()) {
             exit("Date incorecte! Query-ul nu a putut fi executat.");
         }
     }
     /*	SQL Server
     			 * 
     			$db = new DBMssql(false);
     			if($output->action == "select")
     				return $db->_executeSelectAct($output);
     			else if($output->action == "insert")
     				return $db->_executeInsertAct($output);
     			else if($output->action == "delete")
     				return $db->_executeDeleteAct($output);				
     			else if($output->action == "update")
     				return $db->_executeUpdateAct($output);
     			*/
     /*
      * Mysql  
      */
     $db = new DBMysql(false);
     if ($output->action == "select") {
         $db->_executeSelectAct($output);
     } else {
         if ($output->action == "insert") {
             $db->_executeInsertAct($output);
         } else {
             if ($output->action == "delete") {
                 $db->_executeDeleteAct($output);
             } else {
                 if ($output->action == "update") {
                     $db->_executeUpdateAct($output);
                 }
             }
         }
     }
     return $db->getLatestQuery();
 }
예제 #14
0
 /**
 @brief
 @developer
 @return
 @access
 @param $target_name
 */
 public function isTableExists($target_name)
 {
     parent::isTableExists($target_name);
     return FALSE;
 }
예제 #15
0
<?php

$db = new DBMysql('localhost', 'user', 'password');
$db->connect('database_name');
return $db;
예제 #16
0
파일: status.php 프로젝트: pvasener/glpi
            } else {
                echo "GLPI_DBSLAVE_{$num}_OK\n";
            }
        }
    }
} else {
    echo "No slave DB\n";
}
// Check main server connection
if (DBConnection::establishDBConnection(false, true, false)) {
    echo "GLPI_DB_OK\n";
} else {
    echo "GLPI_DB_PROBLEM\n";
    $ok_master = false;
}
if (!empty(DBMysql::checkForCrashedTables())) {
    echo "GLPI_TABLES_KO\n";
} else {
    echo "GLPI_TABLES_OK\n";
}
// Slave and master ok;
$ok = $ok_slave && $ok_master;
// Check session dir (usefull when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
    echo "GLPI_SESSION_DIR_OK\n";
} else {
    echo "GLPI_SESSION_DIR_PROBLEM\n";
    $ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
 function afterSave()
 {
     $name = $this->getParam('name');
     $key_field_value = $this->getParam('key_field_value');
     $many_to_many_table = $this->getParam('many_to_many_table');
     $link_field = $this->getParam('link_field');
     $lookup_field = $this->getParam('lookup_field');
     $many_to_many_table_filters = $this->getParam('many_to_many_table_filters');
     $db = DBMysql::getInstance();
     /// deleting
     $query = "\n\t\t\tDELETE FROM `{$many_to_many_table}`\n\t\t\tWHERE `{$link_field}` = '{$key_field_value}'\n\t\t";
     if ($many_to_many_table_filters && is_array($many_to_many_table_filters)) {
         foreach ($many_to_many_table_filters as $field => $value) {
             $query .= " AND `{$field}` = '{$value}' ";
         }
     }
     $db->setQuery($query);
     if (!$db->query()) {
         $this->errors[] = $db->getError();
         return false;
     }
     // inserting
     if (!isset($_POST[$name])) {
         return true;
     }
     $fields = array($link_field, $lookup_field);
     if ($many_to_many_table_filters && is_array($many_to_many_table_filters)) {
         foreach ($many_to_many_table_filters as $field => $value) {
             $fields[] = $field;
         }
     }
     $insert_params = array();
     foreach ($_POST[$name] as $lookup_value) {
         $values = array($key_field_value, $lookup_value);
         if ($many_to_many_table_filters && is_array($many_to_many_table_filters)) {
             foreach ($many_to_many_table_filters as $filter_value) {
                 $values[] = $filter_value;
             }
         }
         $insert_params[] = "('" . implode("', '", $values) . "')";
     }
     $insert_str = implode(', ', $insert_params);
     $query = "\n\t\t\tINSERT INTO `{$many_to_many_table}`\n\t\t\t( `" . implode('`, `', $fields) . "` )\n\t\t\tVALUES {$insert_str}\n\t\t";
     $db->setQuery($query);
     if (!$db->query()) {
         $this->errors[] = $db->getError();
         return false;
     }
     return true;
 }
예제 #18
0
파일: test_mysql.php 프로젝트: chaobj001/tt
<?php

//mySQL数据库测试
//by indraw
//2004/11/3
//---------------------------------------------------------
//包含并初始化
error_reporting(E_ERROR | E_WARNING | E_PARSE);
include_once "DBMySQL.class.php";
$db = new DBMysql("root", "", "test", "localhost");
//---------------------------------------------------------
//建立一个数据库]
///$db->query("CREATE TABLE test_table ( ColumnA int(12) auto_increment, ColumnB text, test1 varchar(10), test2 int(12),PRIMARY KEY (`ColumnA`))");
//$db->debug();
//向数据库中插入数据
for ($i = 0; $i < 3; ++$i) {
    //$db->query("INSERT INTO test_table (ColumnB,test1,test2) VALUES ('".md5(microtime())."','168','".time()."')");
    //$db->debug();
}
//计算一个表内的行数
$my_count = $db->get_var("SELECT count(*) FROM test_table");
$db->debug();
//查出一个表内所有的数据
$my_tables = $db->get_results("SELECT * FROM test_table");
$db->debug();
//更新一行记录
$db->query("UPDATE test_table SET test1='解放台湾' WHERE ColumnA ='2'");
$db->debug();
//查出一个表内所有的数据
$my_tables = $db->get_results("SELECT * FROM test_table");
$db->debug();
예제 #19
0
 /**
  * Show the central personal view
  **/
 static function showMyView()
 {
     global $DB, $CFG_GLPI;
     $showticket = Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN));
     $showproblem = Session::haveRightsOr('problem', array(Problem::READALL, Problem::READMY));
     echo "<table class='tab_cadre_central'>";
     if (Session::haveRight("config", UPDATE)) {
         $logins = User::checkDefaultPasswords();
         $user = new User();
         if (!empty($logins)) {
             $accouts = array();
             foreach ($logins as $login) {
                 $user->getFromDBbyName($login);
                 $accounts[] = $user->getLink();
             }
             $message = sprintf(__('For security reasons, please change the password for the default users: %s'), implode(" ", $accounts));
             echo "<tr><th colspan='2'>";
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
         if (file_exists(GLPI_ROOT . "/install/install.php")) {
             echo "<tr><th colspan='2'>";
             $message = sprintf(__('For security reasons, please remove file: %s'), "install/install.php");
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
     }
     if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) {
         if (!DBMysql::isMySQLStrictMode()) {
             echo "<tr><th colspan='2'>";
             $message = __('MySQL strict mode is not enabled');
             Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message);
             echo "</th></tr>";
         }
     }
     if ($DB->isSlave() && !$DB->first_connection) {
         echo "<tr><th colspan='2'>";
         Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", __('MySQL replica: read only'), __('MySQL replica: read only'));
         echo "</th></tr>";
     }
     echo "<tr class='noHover'><td class='top' width='50%'><table class='central'>";
     echo "<tr class='noHover'><td>";
     if (Session::haveRightsOr('ticketvalidation', TicketValidation::getValidateRights())) {
         Ticket::showCentralList(0, "tovalidate", false);
     }
     if ($showticket) {
         if (Ticket::isAllowedStatus(Ticket::SOLVED, Ticket::CLOSED)) {
             Ticket::showCentralList(0, "toapprove", false);
         }
         Ticket::showCentralList(0, "survey", false);
         Ticket::showCentralList(0, "rejected", false);
         Ticket::showCentralList(0, "requestbyself", false);
         Ticket::showCentralList(0, "observed", false);
         Ticket::showCentralList(0, "process", false);
         Ticket::showCentralList(0, "waiting", false);
     }
     if ($showproblem) {
         Problem::showCentralList(0, "process", false);
     }
     echo "</td></tr>";
     echo "</table></td>";
     echo "<td class='top'  width='50%'><table class='central'>";
     echo "<tr class='noHover'><td>";
     Planning::showCentral(Session::getLoginUserID());
     Reminder::showListForCentral();
     if (Session::haveRight("reminder_public", READ)) {
         Reminder::showListForCentral(false);
     }
     echo "</td></tr>";
     echo "</table></td></tr></table>";
 }
예제 #20
0
파일: status.php 프로젝트: stweil/glpi
            } else {
                echo "GLPI_DBSLAVE_{$num}_OK\n";
            }
        }
    }
} else {
    echo "No slave DB\n";
}
// Check main server connection
if (DBConnection::establishDBConnection(false, true, false)) {
    echo "GLPI_DB_OK\n";
} else {
    echo "GLPI_DB_PROBLEM\n";
    $ok_master = false;
}
$crashedTables = DBMysql::checkForCrashedTables();
if (!empty($crashedTables)) {
    echo "GLPI_TABLES_KO\n";
} else {
    echo "GLPI_TABLES_OK\n";
}
// Slave and master ok;
$ok = $ok_slave && $ok_master;
// Check session dir (useful when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
    echo "GLPI_SESSION_DIR_OK\n";
} else {
    echo "GLPI_SESSION_DIR_PROBLEM\n";
    $ok = false;
}
// Reestablished DB connection
 function getRowsCount()
 {
     $db = DBMysql::getInstance();
     $query = "\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM `{$this->table}`\n\t\t";
     if (isset($this->join_table['name'])) {
         $query .= "\n\t\t\t\tINNER JOIN `{$this->join_table['name']}` ON\n\t\t\t\t\t`{$this->join_table['name']}`.`{$this->join_table['join_field']}`\n\t\t\t\t\t\t= `{$this->table}`.`{$this->key_field}`\n\t\t\t";
     }
     if ($this->where_conditions) {
         $query .= ' WHERE ' . $this->getWhereStr();
     }
     $db->setQuery($query);
     $result = $db->getResult();
     if ($result === false) {
         $this->errors[] = $db->getError();
         return false;
     }
     return $result;
 }
예제 #22
0
 /**
  * @brief triggerAroundmapInsert에서 호출하는 함수. 단, sphinx 모듈 사용하지 않을시에만, \n
  * DB에 등록된 좌표들을 기준으로 거리를 계산하여 결과 값 리턴해준다.\n
  * @param $document_srl 문서 번호
  * @param $lat 위도
  * @param $lon 경도
  * @return 현재 위치  주변의 지표를 거리로 계산한 지표 리스트
  */
 function getAroundmapListMysql($document_srl, $lat, $lon)
 {
     $db_info = Context::getDBInfo();
     $sql = "select *, (sqrt((69.1 * abs({$lat} - lat)) * (69.1 * abs({$lat} - lat)) + (53 * abs({$lon} - lon)) * (53 * abs({$lon} - lon)))) * 1.609344 as distance from " . $db_info->db_table_prefix . "_aroundmap having document_srl != " . $document_srl . " order by distance ASC limit 10";
     $mysqlObj = new DBMysql();
     $result = $mysqlObj->_query($sql);
     $output = $mysqlObj->_fetch($result);
     if (!is_array($output)) {
         $array[] = $output;
         return $array;
     } else {
         return $output;
     }
 }
 function save($data)
 {
     $this->setMode('save');
     if (!$this->loadFields()) {
         return false;
     }
     $update_fields_params = array();
     foreach ($this->fields as $field) {
         if ($field['type'] != 'key') {
             $field = array_merge($field, $this->fields_params);
             $update_fields_params[] = $field;
         }
     }
     $renderer = new DMRenderer();
     $renderer->setFields($update_fields_params);
     $renderer->setData($data);
     $renderer->setFieldsPrefix($this->fields_prefix);
     $mode = $this->getMode();
     $aditional_params = array('key_field' => $this->key_field, 'mode' => $mode);
     $renderer->addParams($aditional_params);
     $data = $renderer->getFieldsData();
     if ($data === false) {
         $this->errors = $renderer->getErrors();
         return false;
     }
     $this->key_value = isset($data[$this->key_field]) ? $data[$this->key_field] : 0;
     if ($this->key_field && $this->key_value) {
         $this->addWhereCondition(" `{$this->key_field}` = '{$this->key_value}' ");
         $result = parent::update($data, $this->table);
         if (!$result) {
             return $result;
         }
         $renderer->triggerEvent('afterSave', $this->key_value, $this->table);
         if (!empty($this->join_table['name'])) {
             $this->where_conditions = array();
             $join_table_key_field_value = $data[$this->join_table['key_field']];
             $this->addWhereCondition(" `{$this->join_table['key_field']}` = '{$join_table_key_field_value}' ");
             $result = parent::update($data, $this->join_table['name']);
             $renderer->triggerEvent('afterSave', $this->key_value, $this->table);
         }
     } else {
         $result = parent::insert($data, $this->table);
         $db = DBMysql::getInstance();
         $this->key_value = $db->insertid();
         if (!$result) {
             return $result;
         }
         $renderer->triggerEvent('afterSave', $this->key_value, $this->table);
         if (!empty($this->join_table['name'])) {
             $this->table_fields[] = array('table' => $this->join_table['name'], 'name' => $this->join_table['join_field']);
             $data[$this->join_table['join_field']] = $this->key_value;
             $this->key_field = $this->join_table['key_field'];
             $result = parent::insert($data, $this->join_table['name']);
             $join_table_key_field_value = $db->insertid();
             $renderer->triggerEvent('afterSave', $join_table_key_field_value, $this->join_table['name']);
         }
     }
     if (!$result) {
         return $result;
     }
     return $result;
 }