1
I have a small PHP script to interact with MAKERIOD. When I run select in PHPADMIN I get the return : "Showing 0 - 16 records (total 17, query took 8.0945 seconds.)"
SELECT Tbdiario.cn1, Tbdiario.cn2, Tbdiario.cn3, Tbdiario.cn4, Alunos.cnomealu, Tbmateria.cnomemat FROM tbdiario INNER JOIN tbementa ON Tbdiario.ccodementa = Tbementa.ccodementa INNER JOIN tbmateria ON Tbementa.ncodmat = Tbmateria.ncodmat INNER JOIN alunos ON Tbdiario.ncodaluno = Alunos.ncodaluno INNER JOIN tbturma ON Tbementa.ncodtur = Tbturma.ncodtur WHERE Alunos.ccpf = '13922054765' AND Tbturma.cletivo = '2009'
However I want to run this SELECT within a . PHP passing as parameters the CPF and the ACADEMIC year. But when I put to execute http://localhost/lernotes.php gives out time ; I’ve changed this time limit( what I don’t think is correct ) but returns nothing.
//include_once 'conexao.php';
require "Dbig.class.php";
Header('Content-Type: application/json');
//$c_cpf = $_POST['c_cpf'] ;
//$c_anoletivo = $_POST['c_anoletivo'];
$db = new Db();
$dados=array();
$sqlBusca = 'SELECT Tbdiario.cn1, Tbdiario.cn2, Tbdiario.cn3, Tbdiario.cn4,';
$sqlBusca .=' Alunos.cnomealu, Tbmateria.cnomemat FROM tbdiario ';
$sqlBusca .=' INNER JOIN tbementa ON Tbdiario.ccodementa = Tbementa.ccodementa ';
$sqlBusca .=' INNER JOIN tbmateria ON Tbementa.ncodmat = Tbmateria.ncodmat ';
$sqlBusca .=' INNER JOIN alunos ON Tbdiario.ncodaluno = Alunos.ncodaluno ';
$sqlBusca .=' INNER JOIN tbturma ON Tbementa.ncodtur = Tbturma.ncodtur ';
$sqlBusca .=' WHERE Alunos.ccpf = "13922054765" ';
$resultado = $db->query($sqlBusca);
if ($resultado)
{
while ($array = mysqli_fetch_assoc($resultado))
{
$dados[] = $array;
}
echo json_encode($dados);
}
else{
echo "VAZIO !!!";
}
?>
<?php
/**
* conexão com o banco de dados usando mysqli
*/
class Db{
private $con;
// Faz a conexão com o banco assim que o objeto é criado
function __construct(){
$this->con = mysqli_connect('localhost', 'root', '', 'dbcadastro');
if (mysqli_connect_errno($this->con)) {
echo "Problemas para conectar no banco. Verifique os dados!";
die();
}
}
// Faz a consulta sql
public function query($sql){
return mysqli_query($this->con, $sql);
}
}
?>
Which version of php is installed?
– Victor Eyer
Xampp 3.22 Apache/2.4.17 (Win32) Openssl/1.0.2d PHP/5.5.33 Database client version: libmysql - mysqlnd 5.0.11 PHP Version 5.5.33
– Rogerio Rios
Se eu troco aquele SELECT por esse $sqlBusca = 'SELECT Alunos.cnomealu,Alunos.ccpf,Tbdiario.cn1,Tbdiario.cn2,Tbdiario.cn3 FROM alunos INNER JOIN tbdiario ON Alunos.ncodaluno=Tbdiario.ncodaluno WHERE Alunos.ccpf =13922054765'; funciona .... but I need the ANOLETIVO field and therefore several INNER JOIN
– Rogerio Rios
Could be a problem with Casesensitive, depending on the OS installed.
– Marcondes
Win 7 original .
– Rogerio Rios
Change your SQL to look right as tables and columns are created in the database. I think Phpmyadmin already treats it to disregard.
– Marcondes
Diario - fk ncodalu , Diario - fk ccodementa , Tbementa - fk ncodtur e Tbementa - fk ncodmat é assim...
– Rogerio Rios
Sorry, Marcondes, what do you mean "change your SQL to be right as the tables and columns are created in the database." ?
– Rogerio Rios
Staff, I checked and saw that I had to change the order of the tables : I was DIARIO-EMENTA-MATERIA-ALUNOS-TURMA-MATERIA , in order to show the name of the student , the subject ( discipline ) and the respective grades.
– Rogerio Rios