Yii2 dont work, error Getting unknown property: commonmodelsArticles::id











up vote
0
down vote

favorite












Please help me. At the opening of the site there is an error




Unknown Property – yiibaseUnknownPropertyException Getting unknown
property: commonmodelsArticles::id




I do not know what to do



commonmodelsarticles.php



public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if(empty($this->date) or $this->date == '0000-00-00'){
$this->date = date("j.n.Y");
}
if($this->cat_id !== 11){
if($this->online == 1){
$this->online_text = "Да";
}else{
$this->online_text = "Нет";
}

if(!empty($this->author_link) and $this->author_link != 9){
$user = User::findOne($this->author_link);
$this->author = $user['username']." ".$user['lastname'];
}
}
if(!empty($this->time)){
$time = $this->time;
$time = explode(':',$time);
$h = $time[0];
$m = $time[1];
$s = 0;
}else{
$h = 0;
$m = 0;
$s = 0;
}

if(!empty($this->date)){
$date = $this->date;
$date = explode('.',$date);
$d = $date[0];
$mon = $date[1];
$y = $date[2];
$this->orders = mktime($h,$m,$s,$mon,$d,$y);
}


return true;
}
return false;
}
public static function tableName()
{
return 'Articles';
}


@frontend modulesController



public function actionIndex($id=null)
{
$query = articles::find()->where(['online' => 1]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize'=>6]);
$news = $query->offset($pagination->offset)
->limit($pagination->limit)
->orderBy('id DESC')
->all();

return $this->render('index',[
'arts'=>$news,
'pagination' => $pagination
]);
}


@frontend viewsarticles



<a href="/article/<?echo $art['id']."-".$art['preview'].".html";?>" class="main-page__news__link js-views-link"></a>









share|improve this question









New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • this error usually happens when you don`t define "id" in the model
    – Mehran
    2 days ago












  • Try to var_dump $art and check if exist a property called id
    – Sfili_81
    2 days ago






  • 1




    Hi mate, try using object notation instead of array one. Replace $art['id'] and $art['preview'] with $art->id and $art->preview
    – Damian Dziaduch
    2 days ago










  • $art['id'] notation can be used to access object properties in Yii2 which extends Yii's model class.
    – Borisa Eric
    2 days ago

















up vote
0
down vote

favorite












Please help me. At the opening of the site there is an error




Unknown Property – yiibaseUnknownPropertyException Getting unknown
property: commonmodelsArticles::id




I do not know what to do



commonmodelsarticles.php



public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if(empty($this->date) or $this->date == '0000-00-00'){
$this->date = date("j.n.Y");
}
if($this->cat_id !== 11){
if($this->online == 1){
$this->online_text = "Да";
}else{
$this->online_text = "Нет";
}

if(!empty($this->author_link) and $this->author_link != 9){
$user = User::findOne($this->author_link);
$this->author = $user['username']." ".$user['lastname'];
}
}
if(!empty($this->time)){
$time = $this->time;
$time = explode(':',$time);
$h = $time[0];
$m = $time[1];
$s = 0;
}else{
$h = 0;
$m = 0;
$s = 0;
}

if(!empty($this->date)){
$date = $this->date;
$date = explode('.',$date);
$d = $date[0];
$mon = $date[1];
$y = $date[2];
$this->orders = mktime($h,$m,$s,$mon,$d,$y);
}


return true;
}
return false;
}
public static function tableName()
{
return 'Articles';
}


@frontend modulesController



public function actionIndex($id=null)
{
$query = articles::find()->where(['online' => 1]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize'=>6]);
$news = $query->offset($pagination->offset)
->limit($pagination->limit)
->orderBy('id DESC')
->all();

return $this->render('index',[
'arts'=>$news,
'pagination' => $pagination
]);
}


@frontend viewsarticles



<a href="/article/<?echo $art['id']."-".$art['preview'].".html";?>" class="main-page__news__link js-views-link"></a>









share|improve this question









New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • this error usually happens when you don`t define "id" in the model
    – Mehran
    2 days ago












  • Try to var_dump $art and check if exist a property called id
    – Sfili_81
    2 days ago






  • 1




    Hi mate, try using object notation instead of array one. Replace $art['id'] and $art['preview'] with $art->id and $art->preview
    – Damian Dziaduch
    2 days ago










  • $art['id'] notation can be used to access object properties in Yii2 which extends Yii's model class.
    – Borisa Eric
    2 days ago















up vote
0
down vote

favorite









up vote
0
down vote

favorite











Please help me. At the opening of the site there is an error




Unknown Property – yiibaseUnknownPropertyException Getting unknown
property: commonmodelsArticles::id




I do not know what to do



commonmodelsarticles.php



public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if(empty($this->date) or $this->date == '0000-00-00'){
$this->date = date("j.n.Y");
}
if($this->cat_id !== 11){
if($this->online == 1){
$this->online_text = "Да";
}else{
$this->online_text = "Нет";
}

if(!empty($this->author_link) and $this->author_link != 9){
$user = User::findOne($this->author_link);
$this->author = $user['username']." ".$user['lastname'];
}
}
if(!empty($this->time)){
$time = $this->time;
$time = explode(':',$time);
$h = $time[0];
$m = $time[1];
$s = 0;
}else{
$h = 0;
$m = 0;
$s = 0;
}

if(!empty($this->date)){
$date = $this->date;
$date = explode('.',$date);
$d = $date[0];
$mon = $date[1];
$y = $date[2];
$this->orders = mktime($h,$m,$s,$mon,$d,$y);
}


return true;
}
return false;
}
public static function tableName()
{
return 'Articles';
}


@frontend modulesController



public function actionIndex($id=null)
{
$query = articles::find()->where(['online' => 1]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize'=>6]);
$news = $query->offset($pagination->offset)
->limit($pagination->limit)
->orderBy('id DESC')
->all();

return $this->render('index',[
'arts'=>$news,
'pagination' => $pagination
]);
}


@frontend viewsarticles



<a href="/article/<?echo $art['id']."-".$art['preview'].".html";?>" class="main-page__news__link js-views-link"></a>









share|improve this question









New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Please help me. At the opening of the site there is an error




Unknown Property – yiibaseUnknownPropertyException Getting unknown
property: commonmodelsArticles::id




I do not know what to do



commonmodelsarticles.php



public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if(empty($this->date) or $this->date == '0000-00-00'){
$this->date = date("j.n.Y");
}
if($this->cat_id !== 11){
if($this->online == 1){
$this->online_text = "Да";
}else{
$this->online_text = "Нет";
}

if(!empty($this->author_link) and $this->author_link != 9){
$user = User::findOne($this->author_link);
$this->author = $user['username']." ".$user['lastname'];
}
}
if(!empty($this->time)){
$time = $this->time;
$time = explode(':',$time);
$h = $time[0];
$m = $time[1];
$s = 0;
}else{
$h = 0;
$m = 0;
$s = 0;
}

if(!empty($this->date)){
$date = $this->date;
$date = explode('.',$date);
$d = $date[0];
$mon = $date[1];
$y = $date[2];
$this->orders = mktime($h,$m,$s,$mon,$d,$y);
}


return true;
}
return false;
}
public static function tableName()
{
return 'Articles';
}


@frontend modulesController



public function actionIndex($id=null)
{
$query = articles::find()->where(['online' => 1]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'pageSize'=>6]);
$news = $query->offset($pagination->offset)
->limit($pagination->limit)
->orderBy('id DESC')
->all();

return $this->render('index',[
'arts'=>$news,
'pagination' => $pagination
]);
}


@frontend viewsarticles



<a href="/article/<?echo $art['id']."-".$art['preview'].".html";?>" class="main-page__news__link js-views-link"></a>






php yii yii2






share|improve this question









New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Sfili_81

338313




338313






New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









user316660

1




1




New contributor




user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user316660 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • this error usually happens when you don`t define "id" in the model
    – Mehran
    2 days ago












  • Try to var_dump $art and check if exist a property called id
    – Sfili_81
    2 days ago






  • 1




    Hi mate, try using object notation instead of array one. Replace $art['id'] and $art['preview'] with $art->id and $art->preview
    – Damian Dziaduch
    2 days ago










  • $art['id'] notation can be used to access object properties in Yii2 which extends Yii's model class.
    – Borisa Eric
    2 days ago




















  • this error usually happens when you don`t define "id" in the model
    – Mehran
    2 days ago












  • Try to var_dump $art and check if exist a property called id
    – Sfili_81
    2 days ago






  • 1




    Hi mate, try using object notation instead of array one. Replace $art['id'] and $art['preview'] with $art->id and $art->preview
    – Damian Dziaduch
    2 days ago










  • $art['id'] notation can be used to access object properties in Yii2 which extends Yii's model class.
    – Borisa Eric
    2 days ago


















this error usually happens when you don`t define "id" in the model
– Mehran
2 days ago






this error usually happens when you don`t define "id" in the model
– Mehran
2 days ago














Try to var_dump $art and check if exist a property called id
– Sfili_81
2 days ago




Try to var_dump $art and check if exist a property called id
– Sfili_81
2 days ago




1




1




Hi mate, try using object notation instead of array one. Replace $art['id'] and $art['preview'] with $art->id and $art->preview
– Damian Dziaduch
2 days ago




Hi mate, try using object notation instead of array one. Replace $art['id'] and $art['preview'] with $art->id and $art->preview
– Damian Dziaduch
2 days ago












$art['id'] notation can be used to access object properties in Yii2 which extends Yii's model class.
– Borisa Eric
2 days ago






$art['id'] notation can be used to access object properties in Yii2 which extends Yii's model class.
– Borisa Eric
2 days ago



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






user316660 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410173%2fyii2-dont-work-error-getting-unknown-property-common-models-articlesid%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








user316660 is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















user316660 is a new contributor. Be nice, and check out our Code of Conduct.













user316660 is a new contributor. Be nice, and check out our Code of Conduct.












user316660 is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410173%2fyii2-dont-work-error-getting-unknown-property-common-models-articlesid%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)