diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index f9ce1884a0c..43b05aea150 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -61,5 +61,37 @@ abstract class DoliDB public $ok; public $error; + + + + /** + * Define sort criteria of request + * + * @param string $sortfield List of sort fields + * @param string $sortorder Sort order + * @return string String to provide syntax of a sort sql string + */ + function order($sortfield=0,$sortorder=0) + { + if ($sortfield) + { + $return=''; + $fields=explode(',',$sortfield); + foreach($fields as $val) + { + if (! $return) $return.=' ORDER BY '; + else $return.=','; + + $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); + if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder); + } + return $return; + } + else + { + return ''; + } + } + } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 597cc8e7c53..c50a7ed8925 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -239,7 +239,7 @@ class DoliDBMssql extends DoliDB { return ''; } - + /** * Close database connexion * @@ -525,37 +525,6 @@ class DoliDBMssql extends DoliDB } - /** - * Define sort criteria of request - * - * @param string $sortfield List of sort fields - * @param string $sortorder Sort order - * @return string String to provide syntax of a sort sql string - * TODO Mutualized this into a mother class - */ - function order($sortfield=0,$sortorder=0) - { - if ($sortfield) - { - $return=''; - $fields=explode(',',$sortfield); - foreach($fields as $val) - { - if (! $return) $return.=' ORDER BY '; - else $return.=','; - - $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder); - } - return $return; - } - else - { - return ''; - } - } - - /** * Escape a string to insert data * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index ce1f6b9e3ea..86100d6d7d3 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -257,7 +257,7 @@ class DoliDBMysql extends DoliDB { return explode('.',$this->getVersion()); } - + /** * Return version of database client driver * @@ -267,7 +267,7 @@ class DoliDBMysql extends DoliDB { return mysqli_get_client_info(); } - + /** * Close database connexion @@ -506,37 +506,6 @@ class DoliDBMysql extends DoliDB } - /** - * Define sort criteria of request - * - * @param string $sortfield List of sort fields - * @param string $sortorder Sort order - * @return string String to provide syntax of a sort sql string - * TODO Mutualized this into a mother class - */ - function order($sortfield=0,$sortorder=0) - { - if ($sortfield) - { - $return=''; - $fields=explode(',',$sortfield); - foreach($fields as $val) - { - if (! $return) $return.=' ORDER BY '; - else $return.=','; - - $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder); - } - return $return; - } - else - { - return ''; - } - } - - /** * Escape a string to insert data * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 8a653fc6579..4cc57a880b8 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -262,7 +262,7 @@ class DoliDBMysqli extends DoliDB { return mysqli_get_client_info($this->db); } - + /** * Close database connexion @@ -508,37 +508,6 @@ class DoliDBMysqli extends DoliDB } - /** - * Define sort criteria of request - * - * @param string $sortfield List of sort fields - * @param string $sortorder Sort order - * @return string String to provide syntax of a sort sql string - * TODO Mutualized this into a mother class - */ - function order($sortfield=0,$sortorder=0) - { - if ($sortfield) - { - $return=''; - $fields=explode(',',$sortfield); - foreach($fields as $val) - { - if (! $return) $return.=' ORDER BY '; - else $return.=','; - - $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder); - } - return $return; - } - else - { - return ''; - } - } - - /** * Escape a string to insert data * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index cb63f012114..531427b9547 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -724,37 +724,6 @@ class DoliDBPgsql extends DoliDB } - /** - * Define sort criteria of request - * - * @param string $sortfield List of sort fields - * @param string $sortorder Sort order - * @return string String to provide syntax of a sort sql string - * TODO Mutualized this into a mother class - */ - function order($sortfield=0,$sortorder=0) - { - if ($sortfield) - { - $return=''; - $fields=explode(',',$sortfield); - foreach($fields as $val) - { - if (! $return) $return.=' ORDER BY '; - else $return.=','; - - $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder); - } - return $return; - } - else - { - return ''; - } - } - - /** * Escape a string to insert data * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 5ef26e52885..37460f0e23c 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -391,8 +391,8 @@ class DoliDBSqlite extends DoliDB { return ''; } - - + + /** * Close database connexion * @@ -647,37 +647,6 @@ class DoliDBSqlite extends DoliDB } - /** - * Define sort criteria of request - * - * @param string $sortfield List of sort fields - * @param string $sortorder Sort order - * @return string String to provide syntax of a sort sql string - * TODO Mutualized this into a mother class - */ - function order($sortfield=0,$sortorder=0) - { - if ($sortfield) - { - $return=''; - $fields=explode(',',$sortfield); - foreach($fields as $val) - { - if (! $return) $return.=' ORDER BY '; - else $return.=','; - - $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - if ($sortorder) $return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder); - } - return $return; - } - else - { - return ''; - } - } - - /** * Escape a string to insert data *