0

I have the following array returned after a fetchAll command

Array ( [0] => Array ( [Name] => tbl_events [0] => tbl_events [Engine] => MyISAM 
[1] => MyISAM [Version] => 10 [2] => 10 [Row_format] => Dynamic [3] => Dynamic 
[Rows] => 9 [4] => 9 [Avg_row_length] => 214 [5] => 214 [Data_length] => 2148 
[6] => 2148 [Max_data_length] => 281474976710655 [7] => 281474976710655 
[Index_length] => 2048 [8] => 2048 [Data_free] => 216 [9] => 216
[Auto_increment] => 1420 [10] => 1420 [Create_time] => 2019-10-08 15:21:32 
[11] => 2019-10-08 15:21:32 [Update_time] => 2019-10-23 19:00:02 
[12] => 2019-10-23 19:00:02 [Check_time] => 
[13] => [Collation] => latin1_swedish_ci [14] => latin1_swedish_ci [Checksum] => 
[15] => [Create_options] => [16] => [Comment] => [17] => ) )

I'm trying to get the value of Auto_increment and assign it to the variable $newID

The code i am using is

    $sqlNEWID = "SHOW TABLE STATUS LIKE 'tbl_events'";
    $stmt = $conn->prepare($sqlNEWID);
    $stmt->execute();
    $newID_data = $stmt->fetchAll();
    print_r($newID_data);
    $newID = $newID_data['Auto_increment'];

but that isn't returning anything, i'm guessing its because the array is an array or series of arrays within an array?

can someone please enlighten me.

BBLJ84
  • 175
  • 1
  • 12
  • On a side note, if you are trying to tamper with auto-increment value you are doing something nasty. And it will inevitably fire back some say – Your Common Sense Oct 26 '19 at 06:48

1 Answers1

0

i got the desired result by replacing

$newID_data = $stmt->fetchAll();

with

 $newID_data = $stmt->fetch(PDO::FETCH_ASSOC);

problem solved!

BBLJ84
  • 175
  • 1
  • 12