Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
remy-tiitre opened this issue Oct 15, 2012 · 0 comments
Open

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

remy-tiitre opened this issue Oct 15, 2012 · 0 comments

Comments

@remy-tiitre
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant