0

is there a way to parse a SQL statement string into a Zend\Db\Sql\Select object?

something along the lines of:

$sql = 'SELECT * FROM table WHERE col1 = "x"';
$select = new Select();
$select->parseSql($sql);

I have many uses for this, basically maintaining the use of a Select object when executing a raw SQL statement, for example to pass to Zend\Paginator\Adapter\DbSelect without having to write a custom Zend\Paginator\Adapter\DbSelect Class.

1 Answer 1

1

got one answer through a twitter response, specific to the Paginator use case:

$resultSet = iterator_to_array($adapter->query($sql_statement)->execute());
$iteratorAdapter = new ArrayAdapter($resultSet);
$paginator = new Paginator($iteratorAdapter);
Sign up to request clarification or add additional context in comments.

2 Comments

no benefit if you are searching from huge data. On every page it'll send all data, although you'll only see some of data on the page. On every page, you'll execute something like "select * from table_name"
it'll not add limit to your query, whereas when using DbSelect Adapter, Paginator will automatically add limit to your query

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.