开发者

Sqlite3 and PDO issue with ORDER BY

I try to use the SQL statement

SELECT * FROM table ORDER BY column

via an PDO-Object in PHP. Problem is, that I always get an error (Call to a member function fetchall() on a non-object - that means, the query did not return a PDO-object) when using the names of all columnname EXCEPT for ID. When I query

SELECT * FROM table ORDER BY ID

it works. ID is the PRIMARY INTEGER KEY, all other colu开发者_如何学Cmns are TEXT or NUMERIC, neither of them would works with the ORDER BY clause.

Any ideas?


It could be an issue with temporary files as you've suggested in your comment to Frank Heikens's answer.

http://www.sqlite.org/tempfiles.html says:

2.6 Transient Indices

SQLite may make use of transient indices to implement SQL language features such as:

* An ORDER BY or GROUP BY clause
* The DISTINCT keyword in an aggregate query
* Compound SELECT statements joined by UNION, EXCEPT, or INTERSECT

Each transient index is stored in its own temporary file.

If and where files are created is controlled by SQLITE_TEMP_STORE, PRAGMA temp_store and PRAGMA temp_store_directory , see http://www.sqlite.org/pragma.html


Replace your ORDER BY statement with ORDER BY CAST(COLUMN AS REAL). It can sort REAL values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜