A SQL statement is executed via CDbCommand in one of the following two ways:
*
execute(): performs a non-query SQL statement, such as INSERT, UPDATE and DELETE. If successful, it returns the number of rows that are affected by the execution.
*
query(): performs an SQL statement that returns rows of data, such as SELECT. If successful, it returns a CDbDataReader instance from which one can traverse the resulting rows of data. For convenience, a set of queryXXX() methods are also implemented which directly return the query results.
This means I have to know query type( select or insert/update/delete) for every query in advance, however it gives me problems to wrap some 3rd party lib/app into yii extensions, since some of them are using sth like mysql_query() which works for all types of queries.
Does Yii DAO have sth equivalent? if not, I think we should add a universal query method for DAO.
If you don't care about query results, you can always use execute(), even for SELECT statements.
I have thought about it, however this is not a good solution, for instance, in one of my current extension, I need to use the return results as callback params, execute() just can't be used here.