0

So, I created adapter:

$adapter = $this->_getWriteAdapter();

After that I added some attributes for select:

$select = $adapter->select();
$select->from(array('o' => $this->getT...
$select->joinLeft(array('address' => $this->getTable('...
$select->joinLeft(array('oh' => ...

And now select is object: enter image description here How I can submit this query and get response from DB?

Thanks in advance!

I tried:

$data = $adapter->query($select);
$data = $adapter->commit();

But it doesn't work

1

You can look for the answer in the Magento Core files, you have a lot of examples there.

Try using:

$select = $adapter->select()
    ->from(array('o' => $this->getT...
    ->joinLeft(array('address' => $this->getTable('...
    ->joinLeft(array('oh' => ...

$result = $adapter->fetchAll($select);
  • ty. And when I do $adapter->insert( I also need to write $adapter->fetchAll? – Павел Кушнеревич Jul 24 '18 at 9:20
  • No. For read operations use fetch, for write operations, commit. Anyway, try to use magento collections and models whenever you can instead of resource connections. – jcmage Jul 25 '18 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.