本文整理汇总了PHP中format::get_quoted_column_name方法的典型用法代码示例。如果您正苦于以下问题:PHP format::get_quoted_column_name方法的具体用法?PHP format::get_quoted_column_name怎么用?PHP format::get_quoted_column_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format
的用法示例。
在下文中一共展示了format::get_quoted_column_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: primary_key_expression
/**
* determine SQL clause expression to match for data_row primary keys
*
* @return string
*/
public static function primary_key_expression($db_doc, $node_schema, $node_table, $data_row_columns, $data_row)
{
$primary_keys = format_table::primary_key_columns($node_table);
$primary_key_index = xml_parser::data_row_overlay_primary_key_index($primary_keys, $data_row_columns, $data_row_columns);
$primary_key_index = $primary_key_index['base'];
// figure out the primary key expression
$primary_key_expression = array();
foreach ($primary_keys as $primary_column_name) {
if (!isset($primary_key_index[$primary_column_name])) {
throw new exception("primary key column named {$primary_column_name} not found in primary_key_index");
}
$column_index = $primary_key_index[$primary_column_name];
// get the type of the column, chasing foreign keys if necessary
$node_column = dbx::get_table_column($node_table, $primary_column_name);
$value_type = format_column::column_type($db_doc, $node_schema, $node_table, $node_column, $foreign);
$primary_key_expression[] = format::get_quoted_column_name($primary_column_name) . ' = ' . format::value_escape($value_type, $data_row->col[$column_index]);
}
if (count($primary_key_expression) == 0) {
throw new exception($node_table['name'] . " primary_key_expression is empty, determinate loop failed");
}
return implode(' AND ', $primary_key_expression);
}
示例2: get_data_row_update
protected static function get_data_row_update($node_schema, $node_table, $old_data_row_columns, $old_data_row, $new_data_row_columns, $new_data_row, $changed_columns)
{
if (count($changed_columns) == 0) {
throw new exception("empty changed_columns passed");
}
// what columns from new_data_row are different in old_data_row?
// those are the ones to push through the update statement to make the database current
$old_columns = array();
$update_columns = array();
foreach ($changed_columns as $changed_column) {
if (!isset($changed_column['old_col'])) {
$old_columns[] = 'NOTDEFINED';
} else {
$old_col_value = format::column_value_default($node_schema, $node_table, $changed_column['name'], $changed_column['old_col']);
$old_columns[] = $changed_column['name'] . ' = ' . $old_col_value;
}
$update_col_name = format::get_quoted_column_name($changed_column['name']);
$update_col_value = format::column_value_default($node_schema, $node_table, $changed_column['name'], $changed_column['new_col']);
$update_columns[] = $update_col_name . ' = ' . $update_col_value;
}
// if the computed update_columns expression is < 5 chars, complain
// if ( strlen($update_columns) < 5 ) {
// var_dump($update_columns);
// throw new exception(sprintf("%s.%s update_columns is < 5 chars, unexpected", $node_schema['name'], $node_table['name']));
// }
$old_columns = implode(', ', $old_columns);
$update_columns = implode(', ', $update_columns);
// use multiline comments here, so when data has newlines they can be preserved, but upgrade scripts don't catch on fire
$sql = sprintf("UPDATE %s SET %s WHERE (%s); /* old values: %s */\n", format::get_fully_qualified_table_name($node_schema['name'], $node_table['name']), $update_columns, dbx::primary_key_expression(dbsteward::$new_database, $node_schema, $node_table, $new_data_row_columns, $new_data_row), $old_columns);
return $sql;
}
示例3: get_foreign_key_reference_sql
public static function get_foreign_key_reference_sql($foreign)
{
return format::get_fully_qualified_table_name($foreign['schema']['name'], $foreign['table']['name']) . ' (' . format::get_quoted_column_name($foreign['column']['name']) . ')';
}