@@ -955,20 +955,37 @@ public function create(string $table = null, ...$schemas)
955955 return false ;
956956 }
957957
958- // todo not finish, not tested
959- public function alter (string $ table = null , ...$ schemas )
958+ /**
959+ * Modify columns in an existing database table, by either:
960+ *```js
961+ * - array( column_name, datatype, ...value/options arguments ) // calls create_schema()
962+ * - addColumn( column_name, datatype, ...value/options arguments ) // returns string
963+ * - dropColumn( column_name ) // returns string
964+ * - changingColumn( column_name, datatype, ...value/options arguments ) // returns string
965+ *```
966+ * @param string $table The name of the db table that you wish to alter
967+ * @param array ...$alteringSchema An array of:
968+ *
969+ * - @param string `$name,` - column name
970+ * - @param string `$type,` - data type for the column
971+ * - @param mixed `$size,` | `$value,`
972+ * - @param mixed `...$anyOtherArgs`
973+ *
974+ * @return mixed results of query() call
975+ */
976+ public function alter (string $ table = null , ...$ alteringSchema )
960977 {
961- if (empty ($ table ) || empty ($ schemas ))
978+ if (empty ($ table ) || empty ($ alteringSchema ))
962979 return false ;
963980
964981 $ sql = 'ALTER TABLE ' . $ table . ' ' ;
965982
966983 $ skipSchema = false ;
967- if (\is_string ($ schemas [0 ])) {
984+ if (\is_string ($ alteringSchema [0 ])) {
968985 $ data = '' ;
969986 $ allowedTypes = ezSchema::ALTERS ;
970987 $ pattern = "/ " . \implode ('| ' , $ allowedTypes ) . "/i " ;
971- foreach ($ schemas as $ types ) {
988+ foreach ($ alteringSchema as $ types ) {
972989 if (\preg_match ($ pattern , $ types )) {
973990 $ data .= $ types ;
974991 $ skipSchema = true ;
@@ -978,7 +995,7 @@ public function alter(string $table = null, ...$schemas)
978995 }
979996
980997 if (!$ skipSchema )
981- $ schema = $ this ->create_schema (...$ schemas );
998+ $ schema = $ this ->create_schema (...$ alteringSchema );
982999
9831000 $ alterTable = !empty ($ schema ) ? $ sql . $ schema . '; ' : null ;
9841001 if (\is_string ($ alterTable ))
0 commit comments