classes/sql.php
/**
	 * Enclose the columns(s) with the proper identifier. This function
	 * will not alter column values that contain functions or identifiers.
	 * Defaults to the "double-quote" as the column/table identifier.
	 *
	 * @param array|string $columns to add identifiers around
	 * @return string
	 */
Enclose the columns(s) with the proper identifier. This function
will not alter column values that contain functions or identifiers.
Defaults to the "double-quote" as the column/table identifier.

@param array|string $columns to add identifiers around
@return string
Enclose the columns ( s ) with the proper identifier . This function will not alter column values that contain functions or identifiers . Defaults to the " double - quote " as the column / table identifier . @param array|string $columns to add identifiers around @return string
public function quote_columns($columns)
	{
		if( ! is_array($columns))
		{
			if(strpos($columns, '(') !== FALSE)
			{
				return $columns;
			}
			if(strpos($columns, ',') !== FALSE)
			{
				$columns = explode(',', $columns);
			}
			else
			{
				$columns = array($columns);
			}
		}
		$fields = array();
		foreach($columns as $column)
		{
			$column = trim($column);
			if(strpos($column, '"') !== FALSE OR strpos($column, '(') !== FALSE)
			{
				$fields[] = $column;
				continue;
			}
			if(strpos($column, '.') !== FALSE)
			{
				$column = explode('.', $column);
				$column = implode('"."', $column);
			}
			$column = '"'.$column.'"';
			$column = str_replace('"*"', '*', $column);
			$fields[] = $column;
		}
		return implode(',', $fields);
	}
public function quote_columns ( $ columns ) { if ( ! is_array ( $ columns ) ) { if ( strpos ( $ columns , '(' ) !== FALSE ) { return $ columns ; } if ( strpos ( $ columns , ',' ) !== FALSE ) { $ columns = explode ( ',' , $ columns ) ; } else { $ columns = array ( $ columns ) ; } } $ fields = array ( ) ; foreach ( $ columns as $ column ) { $ column = trim ( $ column ) ; if ( strpos ( $ column , '"' ) !== FALSE OR strpos ( $ column , '(' ) !== FALSE ) { $ fields [ ] = $ column ; continue ; } if ( strpos ( $ column , '.' ) !== FALSE ) { $ column = explode ( '.' , $ column ) ; $ column = implode ( '"."' , $ column ) ; } $ column = '"' . $ column . '"' ; $ column = str_replace ( '"*"' , '*' , $ column ) ; $ fields [ ] = $ column ; } return implode ( ',' , $ fields ) ; }
Enclose the columns(s) with the proper identifier.
Enclose the columns ( s ) with the proper identifier .
// Conver columns into an array // If this is a complex SELECT clause // Break apart the columns // If it is already quoted - or contains functions like "MAX()" //Break up database.table.column names to quote the inside // Wrap final string // Fix any * that were quoted by accedent