rafaelbandeira3/linkable — Issue #4: Linked tables names SQL join includes prefix twice in CakePHP 1.3.13
Author: olafrv
Created: 2012-01-11 06:01:30+00:00
State: open

When using Linkable behavior in CakePHP 1.3.13 tablenames in SQL instruction generated by a "find" statement produces errors because tablenames include table prefix twice:

Prefix: tbl
Model: User
Table: user

Generated SQL statement produces: `tbl_`tbl_user``

The solution is to modify the Linkable behavior in the 140 line:

if (empty($options['table'])) {
$options['table'] = $db->fullTableName($_Model, true);
}

With:
if (empty($options['table'])) {
$options['table'] = $_Model->table;
}

This is because if you see CakePHP 1.3.13 changelog:
http://cakephp.org/changelogs/1.3.13

Now calling fullTableName is not need internally anymore while translating a join:

[3becdc5] Removing uses of db->fullTableName() when creating joins. Refs #2074
https://github.com/cakephp/cakephp/commit/3becdc5

[6afa21c] find with joins option now respects prefix set in database configuration, fixes #1517 test to prove validity of ticket #1517
https://github.com/cakephp/cakephp/commit/6afa21c