58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* MLP2 site relations reader.
|
|
*
|
|
* Reads all site connection rows from the MLP2 backup site_relations table.
|
|
*
|
|
* MLP2 site_relations schema:
|
|
* site_1 INT UNSIGNED -- lower site ID
|
|
* site_2 INT UNSIGNED -- higher site ID
|
|
* PRIMARY KEY (site_1, site_2)
|
|
*
|
|
* @package Robotstxt_Mlp2_Mlp5
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations
|
|
*/
|
|
class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations {
|
|
|
|
/**
|
|
* Return all MLP2 site relation rows as an array of associative arrays.
|
|
*
|
|
* Each element has keys: site_1 (int), site_2 (int).
|
|
*
|
|
* @return array[]
|
|
*/
|
|
public static function get_all(): array {
|
|
global $wpdb;
|
|
|
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
|
$table = $mlp2->get_site_relations_table();
|
|
|
|
if ( '' === $table ) {
|
|
return array();
|
|
}
|
|
|
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
|
$rows = $wpdb->get_results( "SELECT site_1, site_2 FROM `{$table}`", ARRAY_A );
|
|
|
|
if ( ! is_array( $rows ) ) {
|
|
return array();
|
|
}
|
|
|
|
$result = array();
|
|
foreach ( $rows as $row ) {
|
|
$result[] = array(
|
|
'site_1' => (int) $row['site_1'],
|
|
'site_2' => (int) $row['site_2'],
|
|
);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|