When building propel query, is it possible to get final SQL as string?

U039B0RUXMF
U039B0RUXMF Posts: 39 πŸ§‘πŸ»β€πŸš€ - Cadet
edited June 2023 in Propel ORM

When building propel query, is it possible to get final SQL as string?

Tagged:

Best Answer

  • Alberto Reyer
    Alberto Reyer Posts: 690 πŸͺ - Explorer
    Answer βœ“

    Only via debugger when it's executed (\Propel\Runtime\ActiveQuery\QueryExecutor\AbstractQueryExecutor::executeStatement) which has the advantage that you can see the passed in parameters as well.

    You can also set $config[PropelConstants::PROPEL_DEBUG] = true to log all queries into a log file.

Answers

  • U017Y69D9U4
    U017Y69D9U4 Posts: 34 πŸ§‘πŸ»β€πŸš€ - Cadet

    I think on the query object you can call toString() or something similar which should give you the actual SQL query?

  • Alberto Reyer
    Alberto Reyer Posts: 690 πŸͺ - Explorer
    Answer βœ“

    Only via debugger when it's executed (\Propel\Runtime\ActiveQuery\QueryExecutor\AbstractQueryExecutor::executeStatement) which has the advantage that you can see the passed in parameters as well.

    You can also set $config[PropelConstants::PROPEL_DEBUG] = true to log all queries into a log file.