本文整理汇总了PHP中PMA\libraries\Util::getUniqueCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::getUniqueCondition方法的具体用法?PHP Util::getUniqueCondition怎么用?PHP Util::getUniqueCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA\libraries\Util
的用法示例。
在下文中一共展示了Util::getUniqueCondition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: zoomSubmitAction
/**
* Zoom submit action
*
* @param string $dataLabel Data label
* @param string $goto Goto
*
* @return void
*/
public function zoomSubmitAction($dataLabel, $goto)
{
//Query generation part
$sql_query = $this->_buildSqlQuery();
$sql_query .= ' LIMIT ' . $_POST['maxPlotLimit'];
//Query execution part
$result = $this->dbi->query($sql_query . ";", null, DatabaseInterface::QUERY_STORE);
$fields_meta = $this->dbi->getFieldsMeta($result);
$data = array();
while ($row = $this->dbi->fetchAssoc($result)) {
//Need a row with indexes as 0,1,2 for the getUniqueCondition
// hence using a temporary array
$tmpRow = array();
foreach ($row as $val) {
$tmpRow[] = $val;
}
//Get unique condition on each row (will be needed for row update)
$uniqueCondition = Util::getUniqueCondition($result, count($this->_columnNames), $fields_meta, $tmpRow, true, false, null);
//Append it to row array as where_clause
$row['where_clause'] = $uniqueCondition[0];
$tmpData = array($_POST['criteriaColumnNames'][0] => $row[$_POST['criteriaColumnNames'][0]], $_POST['criteriaColumnNames'][1] => $row[$_POST['criteriaColumnNames'][1]], 'where_clause' => $uniqueCondition[0]);
$tmpData[$dataLabel] = $dataLabel ? $row[$dataLabel] : '';
$data[] = $tmpData;
}
unset($tmpData);
//Displays form for point data and scatter plot
$titles = array('Browse' => Util::getIcon('b_browse.png', __('Browse foreign values')));
$this->response->addHTML(Template::get('table/search/zoom_result_form')->render(array('_db' => $this->db, '_table' => $this->table, '_columnNames' => $this->_columnNames, '_foreigners' => $this->_foreigners, '_columnNullFlags' => $this->_columnNullFlags, '_columnTypes' => $this->_columnTypes, 'titles' => $titles, 'goto' => $goto, 'data' => $data)));
}
示例2: _getMultiRowOperationLinks
/**
* Prepare multi field edit/delete links
*
* @param integer &$dt_result the link id associated to the query which
* results have to be displayed
* @param array $analyzed_sql_results analyzed sql results
* @param string $del_link the display element - 'del_link'
*
* @return string $links_html html content
*
* @access private
*
* @see getTable()
*/
private function _getMultiRowOperationLinks(&$dt_result, $analyzed_sql_results, $del_link)
{
$links_html = '<div class="print_ignore" >';
$url_query = $this->__get('url_query');
$delete_text = $del_link == self::DELETE_ROW ? __('Delete') : __('Kill');
$links_html .= '<img class="selectallarrow" width="38" height="22"' . ' src="' . $this->__get('pma_theme_image') . 'arrow_' . $this->__get('text_dir') . '.png' . '"' . ' alt="' . __('With selected:') . '" />';
$links_html .= '<input type="checkbox" ' . 'id="resultsForm_' . $this->__get('unique_id') . '_checkall" ' . 'class="checkall_box" title="' . __('Check all') . '" /> ' . '<label for="resultsForm_' . $this->__get('unique_id') . '_checkall">' . __('Check all') . '</label> ' . '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
$links_html .= Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Edit'), 'b_edit.png', 'edit');
$links_html .= Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_copy', __('Copy'), 'b_insrow.png', 'copy');
$links_html .= Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png', 'delete');
if ($analyzed_sql_results['querytype'] == 'SELECT') {
$links_html .= Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export');
}
$links_html .= "</div>\n";
$links_html .= '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($this->__get('sql_query')) . '" />' . "\n";
if (!empty($url_query)) {
$links_html .= '<input type="hidden" name="url_query"' . ' value="' . $url_query . '" />' . "\n";
}
// fetch last row of the result set
$GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
$row = $GLOBALS['dbi']->fetchRow($dt_result);
// $clause_is_unique is needed by getTable() to generate the proper param
// in the multi-edit and multi-delete form
list($where_clause, $clause_is_unique, $condition_array) = Util::getUniqueCondition($dt_result, $this->__get('fields_cnt'), $this->__get('fields_meta'), $row, false, false, $analyzed_sql_results);
unset($where_clause, $condition_array);
// reset to first row for the loop in _getTableBody()
$GLOBALS['dbi']->dataSeek($dt_result, 0);
$links_html .= '<input type="hidden" name="clause_is_unique"' . ' value="' . $clause_is_unique . '" />' . "\n";
$links_html .= '</form>' . "\n";
return $links_html;
}
示例3: exportData
//.........这里部分代码省略.........
}
}
$current_row++;
$values = array();
for ($j = 0; $j < $fields_cnt; $j++) {
// NULL
if (!isset($row[$j]) || is_null($row[$j])) {
$values[] = 'NULL';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
// a number
// timestamp is numeric on some MySQL 4.1, BLOBs are
// sometimes numeric
$values[] = $row[$j];
} elseif (stristr($field_flags[$j], 'BINARY') !== false && isset($GLOBALS['sql_hex_for_binary'])) {
// a true BLOB
// - mysqldump only generates hex data when the --hex-blob
// option is used, for fields having the binary attribute
// no hex is generated
// - a TEXT field returns type blob but a real blob
// returns also the 'binary' flag
// empty blobs need to be different, but '0' is also empty
// :-(
if (empty($row[$j]) && $row[$j] != '0') {
$values[] = '\'\'';
} else {
$values[] = '0x' . bin2hex($row[$j]);
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . Util::sqlAddSlashes(Util::printableBitValue($row[$j], $fields_meta[$j]->length)) . "'";
} elseif (!empty($GLOBALS['exporting_metadata']) && $row[$j] == '@LAST_PAGE') {
$values[] = '@LAST_PAGE';
} else {
// something else -> treat as a string
$values[] = '\'' . str_replace($search, $replace, Util::sqlAddSlashes($row[$j])) . '\'';
}
// end if
}
// end for
// should we make update?
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
$insert_line = $schema_insert;
for ($i = 0; $i < $fields_cnt; $i++) {
if (0 == $i) {
$insert_line .= ' ';
}
if ($i > 0) {
// avoid EOL blank
$insert_line .= ',';
}
$insert_line .= $field_set[$i] . ' = ' . $values[$i];
}
list($tmp_unique_condition, $tmp_clause_is_unique) = Util::getUniqueCondition($result, $fields_cnt, $fields_meta, $row, false, false, null);
$insert_line .= ' WHERE ' . $tmp_unique_condition;
unset($tmp_unique_condition, $tmp_clause_is_unique);
} else {
// Extended inserts case
if ($GLOBALS['sql_insert_syntax'] == 'extended' || $GLOBALS['sql_insert_syntax'] == 'both') {
if ($current_row == 1) {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
} else {
$insert_line = '(' . implode(', ', $values) . ')';
$insertLineSize = mb_strlen($insert_line);
$sql_max_size = $GLOBALS['sql_max_query_size'];
if (isset($sql_max_size) && $sql_max_size > 0 && $query_size + $insertLineSize > $sql_max_size) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
$query_size = 0;
$current_row = 1;
$insert_line = $schema_insert . $insert_line;
}
}
$query_size += mb_strlen($insert_line);
// Other inserts case
} else {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
}
}
unset($values);
if (!PMA_exportOutputHandler(($current_row == 1 ? '' : $separator . $crlf) . $insert_line)) {
return false;
}
}
// end while
if ($current_row > 0) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
return false;
}
}
// We need to SET IDENTITY_INSERT OFF for MSSQL
if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL' && $current_row > 0) {
$outputSucceeded = PMA_exportOutputHandler($crlf . 'SET IDENTITY_INSERT ' . Util::backquoteCompat($table_alias, $compat, $sql_backquotes) . ' OFF;' . $crlf);
if (!$outputSucceeded) {
return false;
}
}
$GLOBALS['dbi']->freeResult($result);
return true;
}