0
I have three tables and want to join them and display them to the user, how can I do this using the functions of Wordpress?
INSERTS THE DATA INTO THE DATABASE:
function cadastra_experiencia($nome, $email, $experiencia){ //INSERE OS DADOS NO BANCO
global $wpdb;
$table = 'experiencia';
$data = array(
'nome' => $nome,
'email' => $email,
'exp' => $experiencia,
);
$updated = $wpdb->insert( $table, $data );
if ( ! $updated ) {
$wpbb->print_error();
}
}
function cadastra_alturapesotipo($altura, $peso, $estilo){
//INSERE OS DADOS NO BANCO
global $wpdb;
$table = 'alturapesoestilo';
$data = array(
'altura' => $altura,
'peso' => $peso,
'estilo' => $estilo,
);
$updated = $wpdb->insert( $table, $data );
if ( ! $updated ) {
$wpbb->print_error();
}
}
BENCH:
CREATE TABLE EXPERIENCIA(
exp_pri INT NOT NULL AUTO_INCREMENT,
nome VARCHAR(150),
email VARCHAR(50),
exp VARCHAR(100),
PRIMARY KEY(exp_pri)
);
CREATE TABLE PRANCHA(
prancha_pri INT NOT NULL AUTO_INCREMENT,
tamanho_prancha VARCHAR(8),
meio_prancha VARCHAR(2),
litragem_prancha VARCHAR(3),
PRIMARY KEY (prancha_pri)
);
CREATE TABLE ALTURAPESOESTILO(
idAltPes INT NOT NULL AUTO_INCREMENT,
idExp INT,
idPrancha INT,
altura VARCHAR(4),
peso VARCHAR(3),
estilo VARCHAR(15),
primary key (idAltPes),
constraint fk_idExp foreign key (idExp) references EXPERIENCIA (exp_pri),
constraint fk_idPrancha foreign key (idPrancha) references PRANCHA (prancha_pri)
);
INNER JOIN:
SELECT EXP.exp,
AEP.altura,
AEP.peso,
AEP.estilo,
PRAN.tamanho_prancha,
PRAN.meio_prancha,
PRAN.litragem_prancha
FROM EXPERIENCIA AS EXP
INNER JOIN ALTURAPESOESTILO AS AEP ON
(EXP.exp_pri = AEP.idAltPes)
INNER JOIN PRANCHA AS PRAN ON
(PRAN.prancha_pri = AEP.idAltPes)
I put on Sqlfiddle for a better view: http://sqlfiddle.com/#! 9/5eb8a/3
I want to display this inner join
for the user (text, Alert, modal), any example/path of how to do this is welcome.
I took a look at the Wordpress Codex, but without much success.