MySQL::BuildSQLColumns PHP Method

BuildSQLColumns() private static method

[STATIC] Builds a comma delimited list of columns for use with SQL
private static BuildSQLColumns ( $columns, boolean $addQuotes = true, boolean $showAlias = true ) : string
$addQuotes boolean (Optional) TRUE to add quotes
$showAlias boolean (Optional) TRUE to show column alias
return string Returns the SQL column list
    private static function BuildSQLColumns($columns, $addQuotes = true, $showAlias = true)
    {
        if ($addQuotes) {
            $quote = "`";
        } else {
            $quote = "";
        }
        switch (gettype($columns)) {
            case "array":
                $sql = "";
                foreach ($columns as $key => $value) {
                    // Build the columns
                    if (strlen($sql) == 0) {
                        $sql = $quote . $value . $quote;
                    } else {
                        $sql .= ", " . $quote . $value . $quote;
                    }
                    if ($showAlias && is_string($key) && !empty($key)) {
                        $sql .= ' AS "' . $key . '"';
                    }
                }
                return $sql;
                break;
            case "string":
                return $quote . $columns . $quote;
                break;
            default:
                return false;
                break;
        }
    }