Zendframework / PgSQL fetchAll orderby
I have a pgsql table with field ids, id, name.
id serial NOT NULL,
identifier character varying(16),
name character varying(128)
I want fetchAll
values from the orderby order id.
but id matters
12, 100, 200, 50
and after $table->fetchAll(null, 'identifier');
gives the result
100, 12, 200, 50
but i want the result to be
12, 50, 100, 200
or using a direct query?
+2
a source to share
2 answers
Try the following:
$table->fetchAll(null, '(identifier+0)');
The operation is +0
to force PostgreSQL to assign the identifier value to an integer, so it is sorted numerically rather than alphabetically.
The parentheses should give Zend Framework a clue to treating the sort argument as an expression rather than a column name.
0
a source to share