FAQ
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'

what am i missing here?

James.

Search Discussions

  • Jess Robinson at Jun 30, 2008 at 10:19 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbix-class @
categoriesperl, catalyst
postedJun 16, '08 at 5:30a
activeJun 30, '08 at 10:19p
posts2
users2
websitedbix-class.org
irc#dbix-class

2 users in discussion

Jess Robinson: 1 post James. L: 1 post

People

Translate

site design / logo © 2022 Grokbase