phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
94 core / field option major always 2003-05-04 16:40 2007-04-15 18:26
anonymous PHP 4.3.1 and MySQL 4.0.12  
michal Windows  
normal 98  
assigned  
open  
none  
none  
Can't handle table names
Works fine with tables with only alphanumeric characters but it doesn't work with tables such as 'sat1-fixtures' which have other characters
Generate a table with a dash in the name and try to make a PHP file using it. Setup works but when the PHP file is run it crashes.
Maybe you need to add ` delimiters to table names and ' to field names
0000094-bq.diff.txt (7 KB) 1970-01-01 01:33

Bug Notes
anonymous   
2003-05-04 20:07   
SOLUTION : in function phpMyEdit($opts) the line reading:-
$this->tb = $opts['tb'];
must be changed to:-
$this->tb = '`'.$opts['tb'].'`';
nepto   
2003-05-07 15:45   
OK, but my question is: if I add ` delimiters, will it work also with old versions of MySQL database server?
nepto   
2003-08-12 12:57   
This was resubmitted in #124:

Cannot handle database with - (dash) character
hbernard   
2003-08-12 16:58   
anonymous :

Why not writing directly
$opts['tb'] = '`my-table`';
for tables whose names are problematic ???

After some test, this workaround seems okay

edited on: 2003-12-21 12:26
nepto   
2004-01-23 17:01   
A workaround was posted in duplicated entry:

http://platon.sk/projects/bug_view_advanced_page.php?f_bug_id=146
hbernard   
2004-01-23 17:50   
But the workaround will fail in case of js validation.
Fix for making workaround work everytime was uploaded in #146
nepto   
2004-04-16 10:40   
Michal pointed me on this:

http://www.mysql.com/doc/en/Legal_names.html
hbernard   
2004-04-16 11:53   
uploaded bq.diff

which make all the table and field's names backquoted.

I certainly missed some SQL operation, but this is a start.

Comments ?
nepto   
2004-04-20 13:47   
Problem is, that old MySQL server does not support these backquotes...

We have two cases:

1. Makes phpMyEdit to work only with new MySQL servers.
2. Detects which version is used and according to this quote or not to quote table/field names.
hbernard   
2004-04-20 13:54   
2b. make a configurable sql_enclosing_delimiter option and use it.
nepto   
2004-04-20 14:40   
Yes, but we can detect this automatically.

Basically I will agree with mentioned approach, but try to read this:

http://www.catb.org/~esr/writings/cups-horror.html

I'm not ESR fan, nor I agree with everything in that article, but in some paragraphs he is certainly right.
hbernard   
2004-04-20 15:53   
OK, So way to solve is :
1. have a $this->enclosing_sql var declared in the class
2. if this is user configurable, test in the constructor
3a. if set, set $this->enclosing_sql = $opts['enclosing_sql']
3b. if not, do autodetection and set $this->enclosing_sql
4. use it in all the querys (but don't enclose 'sql' and 'sqlw' statements.

Two issues :
A) should it be user configurable ?
B) for autodetection, we need to make connection in constructor in place of execute, is it good ?
michal   
2007-04-13 12:37   
partially fixed in cvs (v 1.193).

old versions of MySQL are now _very_ old, so imho no need for configuration. but class allows customization, just need to add child class which will edit function sql_delimiter();
nepto   
2007-04-15 18:08   
Good solution. What else needs to be done, to have this resolved?
michal   
2007-04-15 18:26   
probably just test a little bit. maybe some queries are forgotten....