Exemplo n.º 1
0
/** Create SQL string from field
* @param array basic field information
* @param array information about field type
* @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
*/
function process_field($field, $type_field)
{
    global $jush;
    $default = $field["default"];
    return array(idf_escape(trim($field["field"])), process_type($type_field), $field["null"] ? " NULL" : " NOT NULL", isset($default) ? " DEFAULT " . (preg_match('~time~', $field["type"]) && preg_match('~^CURRENT_TIMESTAMP$~i', $default) || $jush == "sqlite" && preg_match('~^CURRENT_(TIME|TIMESTAMP|DATE)$~i', $default) || $field["type"] == "bit" && preg_match("~^([0-9]+|b'[0-1]+')\$~", $default) || $jush == "pgsql" && preg_match("~^[a-z]+\\(('[^']*')+\\)\$~", $default) ? $default : q($default)) : "", preg_match('~timestamp|datetime~', $field["type"]) && $field["on_update"] ? " ON UPDATE {$field['on_update']}" : "", support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : "", $field["auto_increment"] ? auto_increment() : null);
}
Exemplo n.º 2
0
/** Create SQL string from field
* @param array basic field information
* @param array information about field type
* @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
*/
function process_field($field, $type_field)
{
    return array(idf_escape($field["field"]), process_type($type_field), $field["null"] ? " NULL" : " NOT NULL", isset($field["default"]) ? " DEFAULT " . ($field["type"] == "timestamp" && eregi('^CURRENT_TIMESTAMP$', $field["default"]) || $field["type"] == "bit" && ereg("^([0-9]+|b'[0-1]+')\$", $field["default"]) ? $field["default"] : q($field["default"])) : "", $field["on_update"] ? " ON UPDATE {$field['on_update']}" : "", support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : "", $field["auto_increment"] ? auto_increment() : null);
}