How to remove the red part of the figure?

Asked

Viewed 101 times

2

inserir a descrição da imagem aqui

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'
    )
);

1 answer

5


  • 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.

  • 1

    You need to explain better what you want then.

  • 1

    But it’s not just that $array_banco = $coluna; also seems to be wrong.

  • @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 the while 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.

  • @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.

  • @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.

  • @mustache I understand, I didn’t realize it was fetchall, it’s really correct, it was maybe something just unnecessary. +1

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.