I'm working on a framework in PHP, part of this frameworks job is to write SQL code to generate new MySQL columns.
What is the most elegant way to pass in a bunch of parameters for a column and then turn that into SQL code? As an example here is some YAML I have, that specifies parameters for creating a varchar column:
- type: character
data-type:
type: varchar
length: 255
decimals: null
unsigned: null
zerofill: null
collate: utf8_unicode_ci
character-set: utf8
binary: false
spatial-type: null
values: null
nullify: true
default: null
increment: false
unique: false
primary: false
comment: This is a small general text field.
format: default
storage: default
My design constraints are as follows:
- The YAML cannot contain any SQL syntax
- The PHP code must be as concise as possible.