2
require("setup_do_banco.php");
$colunas = $pdo->prepare("SELECT * FROM origem WHERE ativado = 1");
$colunas->execute();
while ( $coluna = $colunas->fetchAll(PDO::FETCH_ASSOC) ) { $array_banco = $coluna; }
foreach($array_banco as $item){
$fields[] = sprintf("'%s' => '%s'", $item['field'], $item['description']);
}
$array = array (
'key' => '8b0dc65f996f98fd178a9defd0efa077',
'module' => 'imoveis',
'method' => 'busca_imoveis',
'field' => $fields
);
$client = new SoapClient(null, array (
'uri' => 'http://soap.imo.bi/',
'location' =>
'http://soap.imo.bi/soap.dll',
'trace' => 'trace'
)
);
Update 1
I think the code below is more correct, right?
require("setup_do_banco.php");
$colunas = $pdo->prepare("SELECT * FROM origem WHERE ativado = 1");
$colunas->execute();
$array_banco = $colunas->fetchAll(PDO::FETCH_ASSOC);
foreach($array_banco as $item){
###############################################
$fields[$item['field']] = $item['description'];
}
$array = array (
'key' => '8b0dc65f996f98fd178a9defd0efa077',
'module' => 'imoveis',
'method' => 'busca_imoveis',
'field' => $fields
);
$client = new SoapClient(null, array (
'uri' => 'http://soap.imo.bi/',
'location' =>
'http://soap.imo.bi/soap.dll',
'trace' => 'trace'
)
);
I have it
[DATA] => 'Data cadastro'
we achieved that'DATA' => 'Data cadastro'
the field field with single quotes instead of brackets? ... otherwise SOAP does not recognize the command.– Marcos Vinicius
You need to explain better what you want then.
– Maniero
But it’s not just that
$array_banco = $coluna;
also seems to be wrong.– Guilherme Nascimento
@Guilhermenascimento to what I realized (but did not test), not enough to be wrong, only unnecessary. From what I could conclude is that the
$coluna
gets all the array. How it worked, get in thewhile
and plays$coluna
for$array_banco
(why don’t you use$coluna
then? ) and then the loop because right after there’s nothing left to give fetch.– Maniero
@bigown may be confused, but with the
while
it will only reach the last line of the list, IE, being a list of real estate, he is just taking the last and this does not seem to be the right one, since he is working with a "Webservice of real estate load", at least it is what it seems to me.– Guilherme Nascimento
@Guillhermenascimento take a look at the documentation of
fetchAll
, it does not do what you assume. Simply all this line is unnecessary, just carry the call from the function where it is needed.– Maniero
@mustache I understand, I didn’t realize it was
fetchall
, it’s really correct, it was maybe something just unnecessary. +1– Guilherme Nascimento