PDO SHOW TABLES LIKE "?" does not show existing table. Possibly incorrect data for "?"

I know that in mysql exists table with name 3_content_k

Want to check if the table exists

Code is following

$_POST['id'] = '3';
$_POST['suffix_for_table_names'] = '_k';


$stmt_check_if_table_exists_content = $db->prepare(' SHOW TABLES LIKE "?"; ');

$stmt_check_if_table_exists_content->execute( array( 
trim($_POST['id']). 
'_content'. 
trim($_POST['suffix_for_table_names']) 
) );

$check_if_table_exists_content = $stmt_check_if_table_exists_content->fetch(PDO::FETCH_ASSOC);

Get empty array.

But for example here http://sqlfiddle.com/#!9/f032b/1 array not empty

And with such code also not empty

$stmt_check_if_table_exists_content = $db->prepare(' SHOW TABLES LIKE "3_content_k"; ');

$stmt_check_if_table_exists_content->execute(  );

Where is mistake in the first code?

As understand something incorrect here

$stmt_check_if_table_exists_content->execute( array( 
trim($_POST['id']). 
'_content'. 
trim($_POST['suffix_for_table_names']) 
) );

What is incorrect?


Source: mysql

Leave a Reply