/** * 存入VBA配置 */ public function doSetConfig(ZOL_Request $input, ZOL_Response $output) { $Arr = $upArr = array(); $Arr['dbName'] = $input->post('db'); $Arr['tableName'] = $input->post('tbl'); $upArr['content'] = $Arr['content'] = $input->post('con', true) ? substr(ZOL_String::u8conv($input->post('con', true)), 1) : ''; $flag = Helper_Dao::getOne(array('dbName' => 'Db_UserData', 'tblName' => 'vba_config', 'cols' => 'count(*)', 'whereSql' => ' and dbName="' . $Arr['dbName'] . '" and tableName="' . $Arr['tableName'] . '"')); if ($flag) { $data = Helper_Dao::updateItem(array('editItem' => $upArr, 'dbName' => 'Db_UserData', 'tblName' => 'vba_config', 'where' => ' dbName="' . $Arr['dbName'] . '" and tableName="' . $Arr['tableName'] . '"')); } else { $data = Helper_Dao::insertItem(array('addItem' => $Arr, 'dbName' => 'Db_UserData', 'tblName' => 'vba_config')); } if ($data) { echo 1; } exit; }
/** * Query function * @param string $sql */ function query($sql) { if ('' === $sql) { throw new ZOL_Exception('$sql should not be empty!'); } if (false == $this->link) { $this->connect(); } if (!fwrite($this->link, $sql . "\n")) { trigger_error('Send search query failed!', E_USER_WARNING); return false; } $result = ''; while (($line = fgets($this->link, 4096)) !== false) { $result .= $line; } $doc = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA); if (false === $doc) { trigger_error('Invalid document format!', E_USER_WARNING); return false; } $this->res = ZOL_String::u8conv($doc, $this->encoding); return !$this->res['@attributes']['state']; }