Exemple #1
0
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]);
        }
    }
}
Exemple #2
0
 public static function fieldsWithString($formDefinition, $string)
 {
     $retval = array();
     foreach ($formDefinition as $formField) {
         if (strpos($formField, $string) !== false) {
             continue;
         }
         $info = FOORM::parseFormString($formField);
         $field = $info[0];
         $retval[] = $field;
     }
     return $retval;
 }