mirror of
https://github.com/Heretek-AI/heretek-control-core.git
synced 2026-10-12 02:03:55 +00:00
30 lines
611 B
PHP
30 lines
611 B
PHP
<?php
|
|
/**
|
|
* Database Importer.
|
|
*
|
|
* @package EMCP_Tools
|
|
* @since 3.12.0
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
|
|
|
class EMCP_Tools_DB_Importer {
|
|
|
|
public static function import_from_file( string $filepath ): bool {
|
|
global $wpdb;
|
|
if ( ! file_exists( $filepath ) ) { return false; }
|
|
$lines = file( $filepath );
|
|
$query = '';
|
|
foreach ( $lines as $line ) {
|
|
$trimmed = trim( $line );
|
|
if ( '' === $trimmed || 0 === strpos( $trimmed, '--' ) ) { continue; }
|
|
$query .= $line;
|
|
if ( substr( $trimmed, -1 ) === ';' ) {
|
|
$wpdb->query( $query );
|
|
$query = '';
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|