-2
Good morning everyone, I’m trying to create a runtime view.
For this I need to list all the fields of the table and play within the statement the problem is that I can’t transfer the $obj1[0] array to $variable and so list all or concatenate a foreach within the query.
any idea? I thank you.
if(@$_POST['op']=='criaview'){
$bancoview = $_POST['bancotabelas'];
$tabeaview = $_POST['tabelasbanco'];
$pdo = new PDO(DB_SERVER.":host=".DB_HOST.";dbname=".$bancoview,DB_USER,DB_PASSWORD);
$sql1 = $pdo->prepare("SHOW FIELDS FROM ".$tabeaview);
$sql1->execute();
foreach($sql1 as $obj1){
$variavel = $obj1[0];
}
$pdo = new PDO(DB_SERVER.":host=".DB_HOST.";dbname=".$bancoview,DB_USER,DB_PASSWORD);
$sql = $pdo->prepare(
"CREATE VIEW view_".$tabeaview." AS
SELECT
*
/**
".$variavel."<----------------aqui devem aparecer todos os campos
**/
FROM
".$tabeaview."
");
$sql->execute();
}
your code is just that?
– Marcos Vinicius
for the time being.
– Vicente386