Giacomo P. Tue Jul 06 06:56:49 -0400 2010

Subject: Problem with getting started

Hi all,
First of all, I'm very impressed by the "theorical" simplicity of phpactiverecrd.

I'm getting started with phpactiverecord and I'm trying to apply the simple.php example to my database in order to get the values of the attributes in a table.

These are the line of code I'm using:

<?php require_once './php-activerecord/ActiveRecord.php'; ?>
class Users extends ActiveRecord\Model { }
ActiveRecord\Config::initialize(function($cfg) {
$cfg->set_connections(array('development' => 'mysql://*uname*:*pwd*@[...]/bdandreisdb'));

And I'm getting this error:

Fatal error: Uncaught exception 'ActiveRecord\DatabaseException' with message '42S02, 1146, Table 'bdandreisdb.users' doesn't exist' in /home/giacomo/public_html/test/php-activerecord/lib/Connection.php:276 Stack trace: #0 /home/giacomo/public_html/test/php-activerecord/lib/adapters/MysqlAdapter.php(25): ActiveRecord\Connection->query('SHOW COLUMNS FR...') #1 /home/giacomo/public_html/test/php-activerecord/lib/Connection.php(217): ActiveRecord\MysqlAdapter->query_column_info('`users`') #2 /home/giacomo/public_html/test/php-activerecord/lib/Table.php(358): ActiveRecord\Connection->columns('`users`') #3 /home/giacomo/public_html/test/php-activerecord/lib/Table.php(85): ActiveRecord\Table->get_meta_data() #4 /home/giacomo/public_html/test/php-activerecord/lib/Table.php(61): ActiveRecord\Table->__construct('Users') #5 /home/giacomo/public_html/test/php-activerecord/lib/Model.php(725): ActiveRecord\Table::load('Users') #6 /home/giacomo/public_html/test/php-activerecord/lib/Model.php(1428): ActiveRecord\Model::table() #7 [inter in /home/giacomo/public_html/test/php-activerecord/lib/Connection.php on line 276

[...]Table 'bdandreisdb.users' doesn't exist' [...]
It is right, my table's name is 'Users' and I made a Users class extending Model.
It seems that the uppercase characters are set to lowercase:

I'm using the stable version (1.0) of phpactiverecord
PHP version: 5.3.2
mySQL version: 5.1.31

Thank you

Giacomo P. Tue Jul 06 12:57:03 -0400 2010

I just tryied to rename my table "Users" to "users" and it seems to work.
So it is official? phpactiverecord doesn't support table's name with uppercase characters?

Stefan W Tue Jul 06 13:11:57 -0400 2010

It'd probably work if you set the table name explicitly$table_name

otherwise it has to infer what it should be from your model name.

it should probably be something like this:

class Users extends ActiveRecord\Model { 
static $table_name = 'Users';
Giacomo P. Tue Jul 06 14:02:09 -0400 2010

mmmhhhh ... it works ...

Kien La Tue Jul 06 18:02:15 -0400 2010

Ideally it should work without having to explicitly define the table name. I've created a ticket for this

Sinan Eldem Thu Oct 27 14:21:03 -0400 2011


Denis Zorin Wed Feb 04 02:20:08 -0500 2015

Thank you very much, you was very helped me:)