function makeTable($db, $table, $formFields) { $vendor = $db->getAttribute(PDO::ATTR_DRIVER_NAME); $commands = FOORM::formSqlTable($table, $formFields, $vendor); foreach ($commands as $command) { // echo($command);echo("<br/>"); $ret = $db->exec($command); $code = (string) $db->errorCode(); $info = $db->errorInfo(); if ($code == '42S01') { $ret = true; } // Mysql already exists if (stripos($info[2], 'already exists') > 0) { $ret = true; } if ($ret === false) { echo "<p>Error in SQL:</p><p>\n" . $command . "</p>\n"; die($code . ':' . $info[2]); } } }
return true; } else { return false; } } } // If we are running from the command line - do a unit test if (isCli()) { echo "\nparseFormStrong\n"; print_r(FOORM::parseFormString('title:text:required=true:maxlength=25')); print_r(FOORM::parseFormString('description:textarea:required=true:rows=2:cols=25')); print_r(FOORM::parseFormString('sendemail:radio:requred=true:label=bl_sendemail:choices=on,off,part')); echo "\nformSql\n"; echo FOORM::formSql('title:text:required=true:maxlength=25', 'mysql'); echo "\n"; echo FOORM::formSql('id:key', 'sqlite'); echo "\n"; $formFields = array('id:key', 'email:lkey:maxlength=128', 'user_id:integer:unique=true', 'track_id:integer:unique=true', 'title:text:required=true:maxlength=25', 'description:textarea:required=true:rows=2:cols=25', 'sendemail:radio:requred=true:label=bl_sendemail:choices=on,off,part'); echo "\nformSqlFields\n"; echo FOORM::formSqlFields($formFields, 'sqlite'); echo "\n"; echo "\nformSqlKey\n"; echo FOORM::formSqlKey($formFields); echo "\n"; echo "\nformSqlLKey\n"; echo FOORM::formSqlLKey($formFields); echo "\n"; echo "\nformSqlTable\n"; print_r(FOORM::formSqlTable('TEST_Table', $formFields, 'sqlite')); echo "\n"; }