Symfony Propel Pager - what is the right way to send a custom MySQL query?

Here is the query I need to run

SELECT REPLACE (REPLACE (SUBSTRING_INDEX (LOWER (table.url), '/', 3), 'www.', ''), 'Http: //', '') AS domain FROM table GROUP BY domain

But I am having trouble passing such a request to the Propel player as criteria. I was hoping this would work.

$ criteria-> addSelectColumn ('SUBSTRING_INDEX ('. TablePeer :: URL. ', \' / \ ', 3) AS table');

But, unfortunately, this is not so. Any ideas how I could convey this using the criteria method?

UPDATE

For those who are interested, this is what ended up working, thanks!

$ criteria-> addAsColumn ('domain', 'SUBSTRING_INDEX ('. TablePeer :: URL. ', \' / \ ', 3)'); $ Criteria-> addGroupByColumn ('domain');

+3
source share
1 answer

You need to use some combination Criteria::CUSTOM, and addAsColumnthe object of criteria - as you obviously also need to use doSelectRs(<= 1.2) or doSelectStmt(> = 1.3). Im not sure what the exact wording will be, but it can lead you in the right direction (pay attention to the link to 1.2 to update sysntaxt / api if necessary for 1.3 or 1.4).

http://stereointeractive.com/blog/2009/07/21/propel-criteria-on-custom-columns-with-addascolumn/

+3
source

Source: https://habr.com/ru/post/1730890/


All Articles