if ($aff_id && $parent_aff_id){
global $wpdb;
$table = $wpdb->prefix . 'uap_relations';
$sql = "INSERT INTO $table VALUES(NULL, %d, %d)";
var_dump([$aff_id, $parent_aff_id]);
var_dump($sql);
$output = ob_get_clean();
file_put_contents($_SERVER['DOCUMENT_ROOT'].'/cache/log/rel_log1.txt', $aff_id, $parent_aff_id, FILE_APPEND);
exit(); //тут смотреть и думать
$q = $wpdb->prepare($sql, [$aff_id, $parent_aff_id]); //здесь вроде массив должен быть
$wpdb->query($q);
}
CREATE TABLE " . $table_name . " (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
affiliate_id INT(11) NOT NULL,
parent_affiliate_id INT(11) NOT NULL,
INDEX idx_uap_relations_affiliate_id (`affiliate_id`),
INDEX idx_uap_relations_parent_affiliate_id (`parent_affiliate_id`)
public function add_new_relation($aff_id=0, $parent_aff_id=0){
/*
* @param int, int
* @return none
*/
if ($aff_id && $parent_aff_id){
global $wpdb;
$table = $wpdb->prefix . 'uap_relations';
$q = $wpdb->prepare("INSERT INTO $table VALUES(NULL, %d, %d);", $aff_id, $parent_aff_id);
var_dump($aff_id, $parent_aff_id);
$wpdb->query($q);
}
}