views:

175

answers:

2

Hi,

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 columns are TEXT or NUMERIC, neither of them would works with the ORDER BY clause.

Any ideas?

A: 

Why don't you show us the query error? http://nl3.php.net/manual/en/pdo.errorinfo.php

Frank Heikens
Array ( [0] => HY000 [1] => 14 [2] => unable to open database file ) and that's strange because when I don't use the ORDER BY clause this won't happen... Maybe it has to do with a temporary created db for sorting, that can't be saved?
Maenny
A: 

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

VolkerK
Yes, thanks it was the SQLITE_TEMP_STORE variable. I have to change it before using ORDER BY because otherwise sqlite tries to write a temporary file. Also see this: http://www.sqlite.org/tempfiles.html#tempstore
Maenny