As I said in the other topic about using 2 databases (
http://www.pradosoft.com/forum/index.php/topic,6650.0.html) I was trying to use ActiveRecords.
Here is my ActiveRecord Class:
class DUserGroupActiveRecord extends TActiveRecord
{
public $id_grupo = 0;
public $id_parent = 0;
public $nome = null;
public $descricao = null;
public $roles = null;
private static $_tablename = 'novodiretor_2006.usuario_grupo'; //table name
public static function finder()
{
return self::getRecordFinder('DUserGroupActiveRecord');
}
}
The problem is that using 'novodiretor_2006.usuario_grupo' as the table name, I get a TDbException:
TDbCommand failed to prepare the SQL statement "SHOW FULL FIELDS FROM `novodiretor_2006.usuario_grupo`": SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name 'novodiretor_2006.usuario_grupo'
At some point PRADO quote the table name with ` forming the string `novodiretor_2006.usuario_grupo` witch is not a table name
So I tried using 'novodiretor_2006`.`usuario_grupo' as the table name to get `novodiretor_2006`.`usuario_grupo`in the query and that worked but gave me another exception:
TDbCommand failed to prepare the SQL statement "SELECT `id_grupo`, `id_parent`, `nome`, `descricao`, `roles` FROM novodiretor_2006`.`usuario_grupo WHERE `id_grupo` = :id_grupo": SQLSTATE[42000]: Syntax error or access violation: 1064 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 'usuario_grupo WHERE `id_grupo` = ?' at line 1
Notice that now PRADO didn't quote the table name using ` and in this query try to query table novodiretor_2006`.`usuario_grupo instead `novodiretor_2006`.`usuario_grupo`.
All I need is to make the code somewhere (maybe in the TActiveRecord?) to also quote the table name as the first query (SHOW FULL FIELDS...) do OR to stop adding the ` to the first query.