Questions tagged [yii2-model]

Use this tag if your question relates to the Yii2-model-class or one of its descendants.

This tag should be used whenever your question relates to the \yii\base\Model class or one of its descendants like \yii\db\ActiveRecord.

320 questions
-1
votes
0 answers

How can I wirte to log the whole data, or the SQL query running on the background in Yii2 (PHP) framework?

I'm trying to improve this Controller method written in Yii2 (PHP). It passes data to a paginator, but not all data that is available in the database is included. When I sort a column from A to Z, I see the beginning; when I sort from Z to A, I see…
-1
votes
1 answer

Sort gridview with data from 1:n relationship from junction table

i have a 3 table product_tbl // hold product data specification_tbl // hold all type of specification that my product can have product_specification_tbl // (kind of Junction table)hold each Product Specification Value…
-1
votes
1 answer

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'guidian.id' in 'where clause' in yii2

I am new to Yii2 PHP framework, I have student form to get student details and guardian id_no and on submission I get this error SQLSTATE[42S22]: Column not found: 1054 Unknown column 'guidian.id' in 'where clause' The SQL being executed was: SELECT…
Roman
  • 183
  • 3
  • 16
-1
votes
1 answer

3 Different tables have same Foreign Key, How to select

Supposed I have 3 different tables which have identical Foreign Key like below:- Table One product_unit | id | product_id | weight | status_id | |:----|--------------|---------|------------:| | 1 | 4 | 300 | 1 | | …
user3657273
  • 39
  • 2
  • 8
-1
votes
6 answers

How to check is it a backend URL

'urlManagerBackend' => [ 'class' => 'yii\web\urlManager', 'baseUrl' => 'http://backend.test', 'enablePrettyUrl' => true, 'showScriptName' => true, ], then I want to display the image saved under uploads…
-1
votes
1 answer

YII2 - Save user ID to work with it on other pages

I'm building a questionnaire site. On this site the user enters his email to receive the result of his questionnaire. So this site has no authentication. How do I store the user's email to the end of the questionnaire? It is my User…
Hamed
  • 313
  • 2
  • 15
-1
votes
2 answers

Get model by table name in yii2

I have one method in several models, implemented in different ways. I only know the name of table in database. I must find model of this table. How to do? interface BaseIndexedModel { public function writeSometext(); } and some models…
Mary
  • 37
  • 9
-1
votes
1 answer

Yii2 not save many-to-many with new item

There is this code: $new_city = $request->post("new_city_select"); $city = City::find() //find item by name ->where(['=', 'name', $new_city]) ->one();; if ($city == null) { …
kome
  • 51
  • 1
  • 2
  • 5
-1
votes
2 answers

Yii2 Trying to get property of non-object error with listView relational model

I have two tables. students(id,email,password,f_name,l_name,unique_id,create_date,last_update) comments(id,ad_id,commented_user,comment,create_date,last_update) table relation -> comments.commented_user = students.email comments class class…
-1
votes
1 answer

How to check if submitbutton detect click

Hello Please I try learn this tutorial Yii2 tutorial 3 But not working, when I click on submit button not change... if edit it's empty or not... I thing so 'btn btn-success']); ?> not detect click, how…
trip07
  • 187
  • 1
  • 8
-1
votes
3 answers

Create multiple logins in the same browser at same time

I want to create multiple logins at a time on the same browser, like admin and user. For that we are using different models like LoginForm.php and Adminlogin.php and different identity classes, i.e. User.php and Admin.php. But when we login with…
Renu Thakur
  • 551
  • 11
  • 35
-1
votes
2 answers

Get Category names from category_master table in another model's view

I have two different tables: document_master doc_id cat_id doc_name category_master cat_id cat_name cat_desc I want cat_name in dropdown of view file document model. I have created model called catmodel which contains details of…
vijay nathji
  • 1,608
  • 13
  • 23
-1
votes
2 answers

Getting related records only in yii2

Assume this schema: category(id, name) article(id, categoryId, writerId, title, content) writer(id, name, age, location) I want to be able to get all articles written by a specific writer if i am starting at the category level. That is category >…
user2707590
  • 1,066
  • 1
  • 14
  • 28
-2
votes
1 answer

How to make search filters work with formatted dates in Yii2?

$query->andFilterWhere(['like', 'date_of_birth', date('d-m-Y',strtotime($this->date_of_birth))]); It's not working..
-2
votes
1 answer

How to add orderBy() with where() of Find()?

How to add an orderBy() with a where condition? $floor_data = Floors::find()->where(['building_id' => $id])->orderBy->(['floor_no' => SORT_DESC])->all(); This is giving me a syntax error saying syntax error, unexpected '(', expecting identifier…
Sarath C
  • 13
  • 3
1 2 3
21
22