I'm trying to switch from a MySQL database to a SQLAnywhere database (where I'm not in control the table definition). Database connection and simple queries are working fine.
Example of a working query for the MySQL database:
$query = DB::query('SELECT * FROM `Users`');
Example of a working query for the SQLAnywhere database:
$query = DB::query('SELECT * FROM "EM"."Users"');
I notice that I can set the table_prefix for the SQLAnywhere database in the db.php configuration:
'table_prefix' => 'EM.',
However, when I try to use ORM like so:
$entry = Model_User::find('first');
I get the following error, but only for the SQLAnywhere database:
ErrorException [ Error ]: Maximum function nesting level of '100' reached, aborting!
I don't get this error if I change the prefix (e.g. to 'EM_', but then I obviously get a SQL syntax error instead).
Are periods '.' allowed in the table_prefix? Do they need escaping? Is there something else I'm doing wrong?
Can you give more information about this error? Which file and line generates that error? Can you give backtrace? ORM uses the DB classes for database interaction, so in theory it should work fine.
I no longer require an answer to this. The SQLAnywhere syntax wasn't in fact a table prefix. By logging in as the table owner the owner qualifier ("EM") isn't needed in the query.
But I'm still interested why putting a period into table_prefix appeared to cause some kind of recursion overflow.
The problem is that when a dot is detected when quoting the identifier, the identifier is split in parts, a table prefix is added, and then it recuses to quote the parts. Which will contain a dot (due to the prefix that was added), which causes the process to repeat itself.
In most SQL dialects, the dot is used to identify a database name (as in "database.table").