News:

Wondering if this will always be free?  See why free is better.

Main Menu

$smcFunc['db_create_table'] - bug?

Started by inter, September 22, 2012, 09:49:13 AM

Previous topic - Next topic

inter

$columns = array(
array(
'name' => 'id',
'type' => 'int',
'size' => 10,
'unsigned' => TRUE,
'auto' => TRUE,
),
);

$indexes = array(
array(
'name' => 'keys',
'type' => 'unique',
'columns' => array('left_key', 'right_key'),
),
);

$smcFunc['db_create_table']('{db_prefix}my', $columns, $indexes, array());


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 'keys (left_key,right_key), ...

$columns = array(
array(
'name' => 'id',
'type' => 'int',
'size' => 10,
'unsigned' => TRUE,
'auto' => TRUE,
),
);

$indexes = array(
array(
'name' => '`keys`',
'type' => 'unique',
'columns' => array('left_key', 'right_key'),
),
);

$smcFunc['db_create_table']('{db_prefix}my', $columns, $indexes, array());


Good
Sorry for my English

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Arantor

Using reserved words is always a minefield - especially because you have three different systems to deal with (and the suggested code probably wouldn't work properly on the other systems as they do things differently anyway)

So ultimately, we've taken the decision that this is not going to be changed; just because you *can* force it to use a keyword as a column or index doesn't mean you *should* especially as it means that in a query you should generally backtick or otherwise escape it (which can have problems in itself)

The solution is not to use keywords in the first place ;)

Advertisement: