Browse Source

[svn r11361] Added escape_string() method. Now we have a full range of database methods that can add a layer between the code and the database.

Yannick Warnier 18 years ago
parent
commit
062f646f67
1 changed files with 14 additions and 0 deletions
  1. 14 0
      main/inc/lib/database.lib.php

+ 14 - 0
main/inc/lib/database.lib.php

@@ -27,6 +27,10 @@
 ==============================================================================
 *	This is the main database library for Dokeos.
 *	Include/require it in your code to use its functionality.
+*   Because this library contains all the basic database calls, it could be
+*   replaced by another library for say, PostgreSQL, to actually use Dokeos
+*   with another database (this is not ready yet because a lot of code still
+*   uses the MySQL database functions extensively).
 *
 *	@package dokeos.library
 * 	@todo the table constants have all to start with TABLE_
@@ -576,6 +580,16 @@ class Database
 	{
 		return mysql_insert_id();
 	}
+	/**
+	 * Escapes a string to insert into the database as text
+	 * @param	string	The string to escape
+	 * @return	string	The escaped string
+	 * @author	Yannick Warnier <yannick.warnier@dokeos.com>
+	 */
+	function escape_string($string)
+	{
+		return mysql_escape_string($string);
+	}
 	/**
 	 * Gets the array from a SQL result (as returned by api_sql_query) - help achieving database independence
 	 * @param     resource    The result from a call to sql_query (e.g. api_sql_query)