[PHP]idiorm #10 カラム名取得
public function get_columns($table_name,$ignore_clumns = null) { $result = ORM::for_table('information_schema.columns') ->select('column_name') ->where('table_name',$table_name ) ->order_by_expr('ordinal_position') ->find_array(); $columns = array_column($result,'column_name'); if(empty($columns)){ $result = ORM::raw_execute("show columns from {$table_name}"); $statement = ORM::get_last_statement(); $rows = []; $columns = []; while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $columns[] = $row['Field']; } } if(!empty($ignore_clumns)){ $columns = array_diff($columns,$ignore_clumns); } return $columns; }