[Dbix-class] Returning search results in a specific order

Chris Newman Chris.Newman at overturenetworks.com
Tue Apr 30 20:36:50 GMT 2013


You are correct.  Unfortunately, I have copy/paste issues so I retyped and failed miserably.  Not sure the tone was necessary, but your request did bring me to think of comparing my Perl code to the MySQL command I manually executed.



Apparently MySQL sees whitespace differently than I am accustomed to so it turns out the space after FIND_IN_SET was triggering the error.  After that started working the results were still not in the order I wanted.  The cause of that also turned out to be the space between each entry in the second argument to the FIND_IN_SET command.



Thanks for the reply.



-----Original Message-----
From: Peter Rabbitson [mailto:rabbit+dbic at rabbit.us]
Sent: Tuesday, April 30, 2013 3:09 PM
To: DBIx::Class user and developer list
Subject: Re: [Dbix-class] Returning search results in a specific order



On Tue, Apr 30, 2013 at 06:21:54PM +0000, Chris Newman wrote:

>

> However, I cannot for the life of me figure out how to do the same thing using DBIx::Class.  My test code looks like this:

> $schema->resultset ('MyTable')->search (id => $ids, { order_by =>

> \'FIND_IN_SET (id, '2, 1, 3') });

>



The thing above isn't valid perl, left alone valid search() syntax.

Please show *actual* code run and *actual* SQL produced.



Cheers



_______________________________________________

List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class

IRC: irc.perl.org#dbix-class

SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/

Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


This email and attachments may contain privileged or confidential information intended only for the addressee(s) indicated. The sender does not waive any of its rights, privileges or protections respecting this information. If you are not the named addressee, an employee, or agent responsible for sending this message to the named addressee (or this message was received by mistake), you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If received in error, please notify us immediately by e-mail, discard any paper copies and delete all electronic files of the email.

Computer viruses can be transmitted via email. The recipient should check this email and any attachments for viruses. Email transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender accepts no liability for any damage caused by any transmitted viruses or errors or omissions in the contents of this message.

Overture Networks, Inc. 637 Davis Drive, Morrisville, NC USA 27560 www.overturenetworks.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130430/a883c416/attachment-0001.htm


More information about the DBIx-Class mailing list