[Dbix-class] FW: Using literal SQL

Dagfinn Ilmari Mannsåker ilmari at ilmari.org
Mon Jan 23 11:51:13 GMT 2017


Hi Francois,

RAPPAZ Francois <francois.rappaz at unifr.ch> writes:

> Hi there,
> My first mail as be truncated, so I repost:
> Can I send a raw sql string to a mysql DB using DBIX::Class ?
> If 
> $schema =  Dbc::Schema->connect( .);
> From the doc (under ResultSet->Search_litteral ) it seems that a $schema->search function exists
> But
> $schema->search(\["select * from  ."]); does not work  (no search method in schema)

That is a typo in the documentation, it should be '$rs->search(\[])'.
Sorry for the confusion.

> Thanks for any suggestion

For completely arbitrary SQL queries you need to use a virtual view:

https://metacpan.org/pod/DBIx::Class::ResultSource::View

> François

Regards,

Ilmari

-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law




More information about the DBIx-Class mailing list