@@ -3067,6 +3067,81 @@ public function testCalcFoundRows() {
30673067 );
30683068 }
30693069
3070+ public function testFoundRowsWithoutSqlCalcFoundRows (): void {
3071+ $ this ->assertQuery ( 'DROP TABLE _dates ' );
3072+ $ this ->assertQuery ( 'DROP TABLE _options ' );
3073+
3074+ // CREATE TABLE
3075+ $ this ->assertQuery ( 'CREATE TABLE t (id INT PRIMARY KEY, value TEXT, INDEX idx_value (value)) ' );
3076+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3077+ $ this ->assertSame ( '0 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3078+
3079+ // INSERT
3080+ $ this ->assertQuery ( 'INSERT INTO t (id) VALUES (1), (2), (3) ' );
3081+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3082+ $ this ->assertSame ( '0 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3083+
3084+ // SELECT
3085+ $ this ->assertQuery ( 'SELECT * FROM t ' );
3086+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3087+ $ this ->assertSame ( '3 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3088+
3089+ // DESCRIBE
3090+ $ this ->assertQuery ( 'DESCRIBE t ' );
3091+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3092+ $ this ->assertSame ( '2 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3093+
3094+ // SHOW COLLATION
3095+ $ this ->assertQuery ( 'SHOW COLLATION ' );
3096+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3097+ $ this ->assertSame ( '7 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3098+
3099+ // SHOW DATABASES
3100+ $ this ->assertQuery ( 'SHOW DATABASES ' );
3101+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3102+ $ this ->assertSame ( '2 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3103+
3104+ // SHOW COLUMNS
3105+ $ this ->assertQuery ( 'SHOW COLUMNS FROM t ' );
3106+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3107+ $ this ->assertSame ( '2 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3108+
3109+ // SHOW CREATE TABLE
3110+ $ this ->assertQuery ( 'SHOW CREATE TABLE t ' );
3111+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3112+ $ this ->assertSame ( '1 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3113+
3114+ // SHOW CREATE TABLE with non-existent table
3115+ $ this ->assertQuery ( 'SHOW CREATE TABLE non_existent_table ' );
3116+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3117+ $ this ->assertSame ( '0 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3118+
3119+ // SHOW INDEX
3120+ $ this ->assertQuery ( 'SHOW INDEX FROM t ' );
3121+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3122+ $ this ->assertSame ( '2 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3123+
3124+ // SHOW GRANTS
3125+ $ this ->assertQuery ( 'SHOW GRANTS ' );
3126+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3127+ $ this ->assertSame ( '1 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3128+
3129+ // SHOW TABLE STATUS
3130+ $ r = $ this ->assertQuery ( 'SHOW TABLE STATUS ' );
3131+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3132+ $ this ->assertSame ( '1 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3133+
3134+ // SHOW TABLES
3135+ $ this ->assertQuery ( 'SHOW TABLES ' );
3136+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3137+ $ this ->assertSame ( '1 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3138+
3139+ // SHOW VARIABLES
3140+ $ this ->assertQuery ( 'SHOW VARIABLES ' );
3141+ $ result = $ this ->assertQuery ( 'SELECT FOUND_ROWS() ' );
3142+ $ this ->assertSame ( '0 ' , $ result [0 ]->{'FOUND_ROWS() ' } );
3143+ }
3144+
30703145 public function testComplexSelectBasedOnDates () {
30713146 $ this ->assertQuery (
30723147 "INSERT INTO _dates (option_name, option_value) VALUES ('first', '2003-05-27 10:08:48'); "
0 commit comments