4

I want to execute a query like the following query in zf2.

SHOW COLUMNS FROM Mytable LIKE 'Mycolumn'

What is the correct way of doing so?

By the way i am using AbstractTableGateway class.

3 Answers 3

12

I do it like this:

  1. Create an adapter
  2. Pass it to the chosen class and run something like this:

    $sql = "SHOW COLUMNS FROM Mytable LIKE 'Mycolumn'"; 
    
    $statement = $this->adapter->query($sql); 
    return $statement->execute(); 
    
Sign up to request clarification or add additional context in comments.

Comments

2

I know reply on a very old thread, but maybe some one looking for SELECT with LIKE

 $this->table = $data['table'];
    $select = new Select();
    $spec = function (Where $where) {
        $where->like('company', '%1%');
    };
    $select->from($this->table);
    $select->where($spec);
    $resultSet = $this->selectWith($select);
    $resultSet->buffer();
    return $resultSet;

Comments

0

This is Some thing found From Google,Hope This helps u...

use Zend\Db\Sql\Sql;
$sql = new Sql($adapter);
$select = $sql->select(); // @return Zend\Db\Sql\Select
$insert = $sql->insert(); // @return Zend\Db\Sql\Insert
$update = $sql->update(); // @return Zend\Db\Sql\Update
$delete = $sql->delete(); // @return Zend\Db\Sql\Delete

For More Info Visit : click

1 Comment

No, they just work for DML statements. but my query is different. it is a show columns statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.