Skip to content

I think the Zend Db examples should be more SQL centered #4

@remy-tiitre

Description

@remy-tiitre

And what I mean by that is people will have problems like how to issue "SELECT field FROM table WHETE field > value" commands via Zend_Db. They don't have any idea about the object names and relations when they start to use ZF2.

I had the same issue, wondering if I should use $adapter->query() or $sql->select() etc. And thats when I had spend many hours reading docs, watching webinars etc.

When I came to conclusion that $sql->select|insert|update|delete is the most logic route for DML and $adapter is the only way to do Store procedures I still pumped to some problems Zend Db 2.0 has right now. For example its not possible to issue WHERE field < SYSDATE() via $sql->select object. (Recent update in github might have fixed that predicate inside predicate problem, haven't tested yet).

But all that trouble that I have had finding a solution how to do simple everyday queries lead me to a thought that there really should be examples from SQL perspective not Zend Db object perspective.

Just an idea what I mean by examples from SQL perspective:
SELECT * FROM table;

SELECT field1, field2 FROM table WHERE field3 = 'some value' ORDER BY field2 DESC, field2 ASC;

SELECT t1., t2. FROM table1 AS t1 INNER JOIN table2 AS t2 ON t1.id = t2.id;

SELECT COUNT(*) AS total, CONCAT(field1, ' ', field2) AS fields FROM table WHERE field1 > NOW() GROUP BY field3 DESC HAVING field3 IS NOT NULL;

SELECT * FROM table LIMIT 5,10;

CALL someStoreProc(@someParam);

If there would be best practice examples for these queries it would be easy to modify and tweak them so that they would solve most of every day use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions