epilog() public method

### Examples: $query->select('id')->where(['author_id' => 1])->epilog('FOR UPDATE'); $query ->insert('articles', ['title']) ->values(['author_id' => 1]) ->epilog('RETURNING id');
public epilog ( string | Cake\Database\Expression\QueryExpression | null $expression = null )
$expression string | Cake\Database\Expression\QueryExpression | null The expression to be appended
 /**
  * Modifies the original insert query to append a "RETURNING *" epilogue
  * so that the latest insert id can be retrieved
  *
  * @param \Cake\Database\Query $query The query to translate.
  * @return \Cake\Database\Query
  */
 protected function _insertQueryTranslator($query)
 {
     if (!$query->clause('epilog')) {
         $query->epilog('RETURNING *');
     }
     return $query;
 }
示例#2
0
 /**
  * Generates the LIMIT part of a SQL query
  *
  * @param int $limit the limit clause
  * @param \Cake\Database\Query $query The query that is being compiled
  * @return string
  */
 protected function _buildLimitPart($limit, $query)
 {
     if (intval($limit) < 1) {
         return '';
     }
     $endRow = intval($query->clause('offset')) + $limit;
     $origEpilog = $query->clause('epilog');
     $offsetEndWrap = '';
     if (is_array($origEpilog) && array_key_exists('snelgOracleOrigEpilog', $origEpilog)) {
         $offsetEndWrap = empty($origEpilog['snelgOracleOffsetEndWrap']) ? '' : $origEpilog['snelgOracleOffsetEndWrap'];
         $origEpilog = $origEpilog['snelgOracleOrigEpilog'];
     }
     //See note in _buildOffsetPart about ->bind being potentially
     //more efficient here
     $query->epilog(['snelgOracleOrigEpilog' => $origEpilog, 'snelgOracleLimitEndWrap' => ") a WHERE ROWNUM <= {$endRow}", 'snelgOracleOffsetEndWrap' => $offsetEndWrap]);
     return 'SELECT /*+ FIRST_ROWS(n) */ a.*, ROWNUM snelg_oracle_sub_rnum FROM (';
 }