1
Good afternoon. I am trying to make the tables be automatically listed, without me having to name the field. But it’s showing errors.
$conn = new PDO($dsn, $username, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $conn->query("SHOW TABLES");
while ($row = $result->fetch(PDO::FETCH_NUM)){
$table = $conn->query("SHOW FULL COLUMNS FROM ".$row[0]);
$busca = $conn->query("SELECT * FROM ".$row[0]);
$rows = '';
echo '<br>';
while ($res = $table->fetch(PDO::FETCH_NUM)){
echo $res[0].'<br>';
while ($resS = $busca->fetch(PDO::FETCH_ASSOC)){
$rows = $res[0] .' - '. $resS[$res[0]].'<br>';
echo $rows;
}
}
}
$res[0] is listing the name of the fields correctly:
idCliente
cliente_Nome
cliente_Cpf
cliente_Endereco
cliente_Numero
cliente_Bairro
cliente_Cidade
cliente_Estado
But when I try to use the data of each table, returned by $ress, it does not present the entered values, or when it shows only the id or duplicates.
It worked out buddy. All I’m doing is to try to check two databases and after the comparison do a synchronization. You have a basis beyond that for me to follow?
– José Luis
Look, if I were to do something similar, I would read the records of a bank and pick up some key fields to see if these fields exist in the other bank. For example in a customer register, I would take the CPF field to make this comparison. If it doesn’t exist, write there. I believe someone with more experience has been through it.
– Rodrigo Tognin
Just one thing, Luis, if the solution has served you, please mark the answer as Resolved. Thank you!
– Rodrigo Tognin
I will try, because there is a client who wants my system both local and web. Dai I could not find any library that does this synchronization. So kind of desperate. I’ve tried mysqldump, but it didn’t work. If you know something, pff. I would be eternally grateful!! Vlw right now.
– José Luis
Open a question about it here, Luis. There are a lot of experienced people who can probably help you. Database synchronization is an interesting thing. However, would it be more appropriate after the end of synchronization for both systems to access only one bank?
– Rodrigo Tognin
Yes, I had done so, the two accessed the web, but the client is afraid that if missing internet and such.
– José Luis
I get it... a suggestion (I’m a layman...) that I give would be to every local recording and on the web, if you have a problem recording the web creates some "flag", something saying that the synchronization should be done and then leave a service to be run at dawn, for example, to perform this synchronization if the "flag" is created. Then I would be ensuring that whenever there is a problem, at a certain moment the synchronization will enter.
– Rodrigo Tognin
Okay. Thank you. Let’s try.
– José Luis