Opened 15 years ago
Closed 11 years ago
#10819 closed enhancement (maybelater)
Suggestion: Addition to dbDelta - returns FALSE on mySQL error
Reported by: | tinwatchman | Owned by: | ryan |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8.4 |
Component: | Database | Keywords: | |
Focuses: | Cc: |
Description
I don't have any idea how to submit or recommend a change to the WordPress core, but I'm going to give this a shot anyway... having just spent a lot of time struggling with the dbDelta function while programming a plugin, I had a possible suggestion to make. It strikes me that said function would be a lot easier to use if something similar to the following code was added, starting on line 1363 of wp-admin/includes/upgrade.php:
if($execute) {
$query_error_num = 0;
foreach($allqueries as $query) {
echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
$qresult = $wpdb->query($query);
if ($qresult === false) {
$query_error_num++;
$qerror = 'error' . $query_error_num;
$for_update[$qerror] = "Query error - The following query failed: " . $query;
}
}
}
return $for_update;
There's probably a more optimized way to go about it - programming isn't my strong suit by any stretch of the means - but at least this way errors caused when *creating* tables with the function will return some kind of error message, even if it's PHP only.
Opinions?
This ticket is a mess / 4 years old