[Dbix-class] substring and +select
Jess Robinson
castaway at desert-island.me.uk
Mon Jun 30 22:19:41 BST 2008
On Sun, 15 Jun 2008, James. L wrote:
> hi,
>
> trying to fetch rows with one field substringed
> (mysql). the field is substringed but the result
> contains one field only instead of all fields(there
> are 10 fields per row). here is the code.
>
> $rs = $rs->search( { user_id => $uid },
> {
> +select => [ "substring(content, 1,
> 100)" => 'content' ],
> +as => [ qw/content/ ],
> },
> );
>
> btw, there seems to be more than one way to call sql
> function: +select => [ \"substring(content, 1, 100)" ]
> is the same as above.
>
> here is result of DBIC_TRACE:
>
> SELECT substring(content, 1, 100), content FROM
> reviews me WHERE ( user_id = ? ): '2'
10 fields per row? What does that mean? what SQL do you expect?
Your search call up there is broken because you ask for 2 columns on data
in "+select", but only have one name for them in "+as", you need to name
them both.
Jess
More information about the DBIx-Class
mailing list