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>
php yii yii2
New contributor
add a comment |
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>
php yii yii2
New contributor
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
add a comment |
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>
php yii yii2
New contributor
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
php yii yii2
New contributor
New contributor
edited 2 days ago
Sfili_81
338313
338313
New contributor
asked 2 days ago
user316660
1
1
New contributor
New contributor
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
add a comment |
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
add a comment |
active
oldest
votes
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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