DBD-mysql icon indicating copy to clipboard operation
DBD-mysql copied to clipboard

You have an error in your SQL syntax

Open johnjelinek opened this issue 1 year ago • 8 comments
trafficstars

DBD::mysql version

5.008

MySQL client version

8.4.2

Server version

5.7.32

Operating system version

Rocky Linux 8

What happened?

$dbh->column_info(undef, undef, 'report', undef);
>count_params statement DESCRIBE `report` '%'
	<- dbd_st_prepare
 -> dbd_st_execute for 1498f0378
	>- dbd_st_free_result_sets
	<- dbd_st_free_result_sets RC -1
	<- dbd_st_free_result_sets
mysql_st_internal_execute MYSQL_VERSION_ID 80402
>parse_params statement DESCRIBE `report` '%'
reconnecting
Can't reconnect on unexpected error 1064
		--> do_error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''%'' at line 1 error 1064 recorded: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''%'' at line 1
		<-- do_error

I think it'd be better to have column_info call something like this instead:

$dbh->prepare("SHOW COLUMNS FROM $table_id LIKE " . $dbh->quote('%'))

Other information

No response

johnjelinek avatar Aug 23 '24 04:08 johnjelinek