public static function column_split($column_list, $token_quotes) { $columns = array(); $in_quoted = false; $col = ""; for ($i = 0; $i < strlen($column_list); $i++) { $c = substr($column_list, $i, 1); $c_next = ""; if ($i < strlen($column_list) - 1) { $c_next = substr($column_list, $i + 1, 1); } // quoted string enclosure if (in_array($c, $token_quotes)) { // not escaped apostrophe? if ($c_next != "'") { // invert in_quoted state to represent beginning/end $in_quoted = !$in_quoted; } else { // it is, include it in $c value $c .= $c_next; $i++; } } // not in quoted string and end of token? (comma) if (!$in_quoted && $c == ",") { $col = trim($col); // explicit or capitalized quoted column names "likeThis" are safe to strip as our column list is case senstive // and far simplifies pgsql8_table::add_data_row() sanity check logic $col = sql_parser::quoted_name_strip($col); $columns[] = $col; $col = ''; } else { // not the end, add it to the currently building comma separated value $col .= $c; } } // if there is column name/data remaining, append it to the array if (strlen(trim($col)) > 0) { $columns[] = sql_parser::quoted_name_strip(trim($col)); } return $columns; }