0
I’m trying to create an array with the contents of a tabela
of my banco
but somehow, I tried to do this:
// ATRIBUI UMA CONEXÃO PDO $pdo = Conexao::getInstance(); // ATRIBUI UMA INSTÂNCIA DA CLASSE CRUD $crud = Crud::getInstance($pdo, 'cadAgendaEvento'); // BUSCANDO EVENTOS $sqlEvento = "SELECT * FROM `cadAgendaEvento`"; $dados = array(); foreach ($sqlEvento as $Retorno) { $dados = $Retorno; echo json_encode( array( "success" => 1, "result" => $dados ) ); }
I wonder if this format is correct, apparently not returning me anything.
Hello @Pantera, thanks for the tip, I’m really using the mentioned library, but tell me one thing, this last example takes all the database records and assembles this array?
– adventistapr
@adventistapr, yes. As the third method parameter
getSQLGeneric
, when omitted, contains the valueTRUE
, the variable$dados
will always be an array with all records your query. The documentation of the fetchAll PHP has more details on how this works.– rdleal