Jump to content

flag \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS not working


Recommended Posts

This is my select:

{{$limit 	= 20;}}
{{$page 	= (isset( \IPS\Request::i()->page ) and (intval( \IPS\Request::i()->page ) > 0)) ? \IPS\Request::i()->page : 1;}}
{{$start 	= ( $limit * ( $page - 1 ) );}}
{{$select = \IPS\Db::i()->select( 'cms_custom_database_8.field_68 as nome_do_suplemento, cms_custom_database_8.record_image_thumb as imagem, cms_custom_database_8.primary_id_field as id_do_suplementos, cms_custom_database_8.member_id as autor, cms_custom_database_8.record_updated as data_de_atualizacao, cms_custom_database_8.record_comments as numero_de_comentarios', 'cms_custom_database_8', array( 'field_140=?', $record->primary_id_field ), 'cms_custom_database_8.field_68 ASC', array( $start, $limit ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );}}
{{$total = count( $select );}}

Total should be 64, but it gives me 20, the number of rows used as query LIMIT.

Edited by sobrenome
Link to comment
Share on other sites

1 hour ago, Mark said:

It's no longer supported. Do a separate count query:


{{$total = \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_8', array( 'field_140=?', $record->primary_id_field ) )->first();}}

 

Perfect! Thanks!

Please update the developer docs:

https://invisioncommunity.com/developers/docs/fundamentals/accessing-the-database-r166/

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...