Revision: 1859
http://mrbs.svn.sourceforge.net/mrbs/?rev=1859&view=rev
Author: cimorrison
Date: 2011-08-04 11:18:11 +0000 (Thu, 04 Aug 2011)
Log Message:
-----------
Added database error checking and handling to sql_*_field_info()
Modified Paths:
--------------
mrbs/trunk/web/mysql.inc
mrbs/trunk/web/mysqli.inc
mrbs/trunk/web/pgsql.inc
Modified: mrbs/trunk/web/mysql.inc
===================================================================
--- mrbs/trunk/web/mysql.inc 2011-08-03 16:34:02 UTC (rev 1858)
+++ mrbs/trunk/web/mysql.inc 2011-08-04 11:18:11 UTC (rev 1859)
@@ -386,10 +386,15 @@
'smallint' => 2,
'tinyint' => 1);
- $fields = array();
$res = sql_mysql_query("SHOW COLUMNS FROM $table");
- if ($res && (sql_mysql_count($res) > 0))
+ if ($res === FALSE)
{
+ trigger_error(mysql_error($db_conn), E_USER_WARNING);
+ fatal_error(TRUE, get_vocab("fatal_db_error"));
+ }
+ else
+ {
+ $fields = array();
for ($i = 0; ($row = sql_mysql_row_keyed($res, $i)); $i++)
{
$name = $row['Field'];
@@ -431,8 +436,8 @@
$fields[$i]['length'] = $length;
$fields[$i]['is_nullable'] = $is_nullable;
}
+ return $fields;
}
- return $fields;
}
Modified: mrbs/trunk/web/mysqli.inc
===================================================================
--- mrbs/trunk/web/mysqli.inc 2011-08-03 16:34:02 UTC (rev 1858)
+++ mrbs/trunk/web/mysqli.inc 2011-08-04 11:18:11 UTC (rev 1859)
@@ -416,10 +416,15 @@
'smallint' => 2,
'tinyint' => 1);
- $fields = array();
$res = sql_mysqli_query("SHOW COLUMNS FROM $table");
- if ($res && (sql_mysqli_count($res) > 0))
+ if ($res === FALSE)
{
+ trigger_error(mysqli_error($db_conn), E_USER_WARNING);
+ fatal_error(TRUE, get_vocab("fatal_db_error"));
+ }
+ else
+ {
+ $fields = array();
for ($i = 0; ($row = sql_mysqli_row_keyed($res, $i)); $i++)
{
$name = $row['Field'];
@@ -461,8 +466,8 @@
$fields[$i]['length'] = $length;
$fields[$i]['is_nullable'] = $is_nullable;
}
+ return $fields;
}
- return $fields;
}
Modified: mrbs/trunk/web/pgsql.inc
===================================================================
--- mrbs/trunk/web/pgsql.inc 2011-08-03 16:34:02 UTC (rev 1858)
+++ mrbs/trunk/web/pgsql.inc 2011-08-04 11:18:11 UTC (rev 1859)
@@ -412,15 +412,20 @@
'smallint' => 'integer',
'text' => 'character');
- $fields = array();
$res = sql_pgsql_query("SELECT column_name, data_type, numeric_precision,
character_maximum_length,
character_octet_length,
is_nullable
FROM information_schema.columns
WHERE table_name ='$table'
ORDER BY ordinal_position");
- if ($res && (sql_pgsql_count($res) > 0))
+ if ($res === FALSE)
{
+ trigger_error(pg_result_error($res), E_USER_WARNING);
+ fatal_error(TRUE, get_vocab("fatal_db_error"));
+ }
+ else
+ {
+ $fields = array();
for ($i = 0; ($row = sql_pgsql_row_keyed($res, $i)); $i++)
{
$name = $row['column_name'];
@@ -449,8 +454,8 @@
$fields[$i]['length'] = $length;
$fields[$i]['is_nullable'] = $is_nullable;
}
+ return $fields;
}
- return $fields;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits