When the data table name is changed (a regular prefix is added), must the system modify the SQL statement? The SQL format of the original system is as follows:
Select * from 'table ';
After going online today, you will know:
For other reasons (not mentioned here ).
All data tables must be renamed and all data tables must be prefixed with "nbx_table"
What should I do?
First, should I change the system again? Too much trouble, right?
Second, how can we prevent this from happening next time?
Third, what are the advantages of cms writing like this:
$ This-> FLInfos = $ this-> dsql-> GetOne ("SELECT * FROM '#@__ freelist 'Where aid =' $ fid '");
Reply to discussion (solution)
Some open-source projects (CMS, BLOG, Wiki, framework...) add a prefix to the data table because:
Prevent conflicts with other application systems!
No databases can be created for the rented space. when two or more projects are put in the space, the table names are prone to conflicts.
First, should I change the system again? Too much trouble, right?
This depends on how you access the database. for example, you can directly modify the ing file without modifying the source code of Hibernate and MyBatis.
If you use JDBC to write SQL statements in the source code, there is no way to modify the SQL statements in the source code.
Second, how can we prevent this from happening next time?
Try to use database persistence layer frameworks such as MyBatis and Hibernate.
Third, what are the advantages of cms writing like this: "SELECT * FROM '# @__ freelist 'Where aid =' $ fid '"
Take a closer look at this SQL statement. there is a mark in it, such as #__ freelist, which is replaced with the variable specified in the configuration file when the SQL statement is generated, this can solve your problem.