Hi.
I have a table:
abstract class BaseUsers extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('USERS');
$this->hasColumn('USER_ID', 'integer', 4, array('unsigned' =>
false, 'notnull' => true, 'primary' => true, 'sequence' =>
'"ShareTheMusic"."USERS_USER_ID_seq"'));
$this->hasColumn('LOGIN', 'string', 20, array('fixed' => false,
'notnull' => true, 'primary' => false));
$this->hasColumn('PASSWORD', 'string', 200, array('fixed' =>
false, 'notnull' => true, 'primary' => false));
$this->hasColumn('ADD_DATE', 'timestamp', null, array('notnull' =>
false, 'primary' => false));
}
public function setUp()
{
parent::setUp();
}
}
I want to use:
$userTable =
Doctrine::getTable("USERS");
$user = $userTable->findOneByLogin($_POST['login']);
findOneByLogin dosen't work:
2008-05-15T15:31:12+02:00 ERR (3): Unknown aggregate alias: login
2008-05-15T15:31:12+02:00 DEBUG (7): #0 D:\www\lib\Doctrine-0.11.0\lib
\Doctrine\Query.php(838): Doctrine_Query-
>getSqlAggregateAlias('login')
#1 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Where.php(79):
Doctrine_Query->parseClause('login')
#2 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Condition.php(74):
Doctrine_Query_Where->load('login = ?')
#3 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Abstract.php(1788):
Doctrine_Query_Condition->parse('login = ?')
#4 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query.php(1143):
Doctrine_Query_Abstract->_processDqlQueryPart('where', Array)
#5 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Abstract.php(932):
Doctrine_Query->getSqlQuery(Array)
#6 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Abstract.php(993):
Doctrine_Query_Abstract->_execute(Array)
#7 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Table.php(2094):
Doctrine_Query_Abstract->execute(Array, NULL)
#8 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Table.php(2133):
Doctrine_Table->findOneBy('login', 'asasasasa', NULL)
#9 [internal function]: Doctrine_Table->__call('findOneByLogin',
Array)
I try findOneByLOGIN, and I get:
2008-05-15T15:33:43+02:00 ERR (3): Cannot find by: LOGIN. Invalid
column or relationship alias.
2008-05-15T15:33:43+02:00 DEBUG (7): #0 [internal function]:
Doctrine_Table->__call('findOneByLOGIN', Array)
#1 D:\www\stm\application\controllers\UserController.php(35):
Doctrine_Table->findOneByLOGIN('asasasasa')
'LOGIN' becomes 'L_O_G_I_N' after Doctrine:tableize, so I omit this,
and I have got that select:
"SELECT u.user_id AS u__user_id, u.login AS u__login, u.password AS
u__password, u.add_date AS u__add_date FROM USERS u WHERE u.login = ?
LIMIT 1"
with this:
2008-05-15T15:37:47+02:00 ERR (3): SQLSTATE[42P01]: Undefined table: 7
BŁĄD: relacja "users" nie istnieje
2008-05-15T15:37:47+02:00 DEBUG (7): #0 D:\www\lib\Doctrine-0.11.0\lib
\Doctrine\Connection\Statement.php(244): Doctrine_Connection-
>rethrowException(Object(PDOException),
Object(Doctrine_Connection_Statement))
#1 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Connection.php(979):
Doctrine_Connection_Statement->execute(Array)
#2 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Abstract.php(948):
Doctrine_Connection->execute('SELECT u.user_i...', Array)
#3 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Query\Abstract.php(993):
Doctrine_Query_Abstract->_execute(Array)
#4 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Table.php(2094):
Doctrine_Query_Abstract->execute(Array, NULL)
#5 D:\www\lib\Doctrine-0.11.0\lib\Doctrine\Table.php(2133):
Doctrine_Table->findOneBy('LOGIN', 'asasasasa', NULL)
#6 [internal function]: Doctrine_Table->__call('findOneByLOGIN',
Array)
first line means: 7 Error: relation "users" doesn't exist.
And... How I can use doctrine with UPPERCASED tables and columns?
Paweł Chuchmała