db-tools.php
23 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JFB_Components\Db; |
| 4 | |
| 5 | // If this file is called directly, abort. |
| 6 | if ( ! defined( 'WPINC' ) ) { |
| 7 | die; |
| 8 | } |
| 9 | |
| 10 | class Db_Tools { |
| 11 | |
| 12 | public static function sanitize_column( $name ): string { |
| 13 | if ( ! is_string( $name ) ) { |
| 14 | return ''; |
| 15 | } |
| 16 | |
| 17 | $name = strtolower( $name ); |
| 18 | |
| 19 | return preg_replace( '/[^a-z0-9_\-\`\.]/', '', $name ); |
| 20 | } |
| 21 | |
| 22 | } |
| 23 |