You can override the getSource method to set the prefix:
<?php
class Users extends Phalcon\Mvc\Model
{
public function getSource()
{
return 'my_' . 'users';
}
}
Or, you can set a common base class to set the table prefix for all models:
<?php
class BaseModel extends Phalcon\Mvc\Model
{
public function getSource()
{
return 'my_' . strtolower(get_class($this));
}
}
And use it as base class for your models:
<?php
class Users extends BaseModel
{
}
Or in PHP 5.4 you can create a trait:
<?php
trait CustomPrefix
{
public function getSource()
{
return 'my_' . strtolower(get_class($this));
}
}
Then in your model:
<?php
class Users extends Phalcon\Mvc\Model
{
use CustomPrefix;
}