1.
My server's OS is linux, so table name is case sensitive, and this is my table
CREATE TABLE IF NOT EXISTS `Category` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC))
ENGINE = InnoDB;
This is the class, the case of class name exactly same to table name
class Category extends \Phalcon\Mvc\Model
{
}
But when I use it.
$cate = new Category();
$cate->name="cate name";
$cate->save();
it will throw the exception.
PhalconException: Table "category" doesn't exist on database when dumping meta-data for Category
Why Phalcon will convert my class name to lower case?
I know I can use this to force the table name
public function getSource()
{
return 'Category';
}
But the class name and table name is same, so this function should be optional.
Can I config the DI to prevent Phalcon to convert the case of class name?
2.
This is another table
CREATE TABLE IF NOT EXISTS `EmailActivation` (
`code` VARCHAR(20) NOT NULL,
`isValid` TINYINT(1) NOT NULL,
PRIMARY KEY (`code`))
ENGINE = InnoDB;
I use Developer Tools to generate models for each table, and this is the generated model
class Emailactivation extends \Phalcon\Mvc\Model
{
protected $code;
protected $isValid;
public function setCode($code)
{
$this->code = $code;
return $this;
}
public function setIsvalid($isValid)
{
$this->isValid = $isValid;
return $this;
}
public function getCode()
{
return $this->code;
}
public function getIsvalid()
{
return $this->isValid;
}
}
This class also have incorrect class and function
e.g.
Emailactivation = X
EmailActivation = O
setIsvalid = X
setIsValid = O
getIsvalid = X
getIsValid = O
How to use the tool to generate correct case in class name and function?