Ar Names Parametrs Different From Columns Names


I would ask, can i simple change names of parametrs i Active record?

In example:

$post=new Post;

$post->title='sample post';

$post->content='post body content';


I sure it’s very simple, but when i change column name for example :“title” to “topic”, I think application give me error message. In this problem can i resolve it in active record class, to change variable names? How can i do that? I cant’ find it in Google, so i post here.

If I got you right, you change the filed name in the database from title to topic, right?

Yes in that case you need to change in your code all instances of "title" to "topic".

I agree with Maurizio

Also you could use indirectly way for that for example using setter and getter

public function getTopic() {

return $post->title;


public function setTopic($val) {

$post->title = $val;


now you can use $this->topic = ‘…’; or echo $this->topic;