本文整理汇总了PHP中SQLQuery::get_columns方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::get_columns方法的具体用法?PHP SQLQuery::get_columns怎么用?PHP SQLQuery::get_columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLQuery
的用法示例。
在下文中一共展示了SQLQuery::get_columns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTableColumns
public function getTableColumns($create = true)
{
global $db;
// Make sure we have a table set
if ($this->table == "") {
error_out("No table set.");
return false;
}
$sql = new SQLQuery($this->table);
$sql->international = $this->international;
$columns = $sql->get_columns();
if (!empty($columns)) {
// Table exists -- return the columns
$this->tablecolumns = $columns;
// If table exists and create is set, add any additional columns
if ($create) {
$formcolumns = $this->formToTableColumns(false);
$newcolumns = array_diff(array_keys($formcolumns), array_keys($columns));
if (!empty($newcolumns)) {
$tablename = $this->table;
if ($this->schema != "") {
$tablename = $this->schema . "." . $this->table;
}
$alter_table_column_string = "";
foreach ($newcolumns as $colname) {
if ($alter_table_column_string != "") {
$alter_table_column_string .= ",";
}
$alter_table_column_string .= $colname . " " . $formcolumns[$colname];
$this->tablecolumns[$colname] = $formcolumns[$colname];
}
$alter_table_query = "ALTER TABLE " . $tablename . " ADD(" . $alter_table_column_string . ")";
$ret = $db->execute($alter_table_query);
}
}
return $this->tablecolumns;
} else {
if ($create) {
// Table doesn't exist -- create it from form
$this->tablecolumns = $this->formToTableColumns();
$sql_create = new SQLCreate($this->table, $this->tablecolumns);
$sql_create->international = $this->international;
$sql_create->execute();
return $this->tablecolumns;
} else {
// Table doesn't exist, 'create' set to false: return false
error_out("Table doesn't exist.");
return false;
}
}
}