return the query as the zend string

Asked

Viewed 80 times

1

I have the following code where I need to store inside the $erro_items variable the complete query with the parameters to analyze what is happening, my doubt is, how do I show this query?

$sql = new Sql($this->adapter);
                $query = $sql->insert('reg_c170');
                $query->values($prod);
                $erro_itens = $queryAqui; // preciso ver a query
                $myitens = fopen("./data/log/".date('Y-m-d')."-itens-add.log", "a+");
                fwrite($myitens, $erro_itens."\r\n");
                fclose($myitens);
  • 1

    Try print_r($query->__toString());.

2 answers

-1

$sql = $select->getSqlString();

Whereas $select is a object(Zend\Db\Sql\Select)[421]

-1

I believe you can use:

$query->getSqlString($this->dbAdapter->getPlatform());

assuming you’re inside a Zenddbsql

Reference

Browser other questions tagged

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