If i have employee_id
with integer
(like 1001
) alone, am getting the answer
example the code like this ,
$claimprocess = Employee::find()
->where("employee_id = '1004' and importcompany_id = 1")
->andwhere(" status != 'Deleted' and relationship = 'Self'")
->all();
if i have a employee_id
with combination interger
and character
, am not able get a answer(like E1004
),
example code like below,
$claimprocess = Employee::find()
->where("employee_id = 'E1004' and importcompany_id = 1")
->andwhere(" status != 'Deleted' and relationship = 'Self'")
->all();
When I execute this code, am getting error like below
Exception (Database Exception) 'yii\\db\\Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Champ 'E1004' inconnu dans where clause The SQL being executed was: SELECT * FROM
employee
WHERE (employee_id = E1004 and importcompany_id = 1) AND ( status != 'Deleted' )'
UPDATED:
actually am getting that value(E1004) from another variable, I use the variable instead of value, for understanding purpose I have used a value there in my question
You need to enclose your employee_id
value ie E1004
within quotes its because it contains string literals. So your query looks like a
->where("employee_id = 'E1004' and importcompany_id = 1")
String literals in SQL are denoted with single quotes ( '
). Without them, the database would interpret E1004
as a column name, and fail the query, since your table doesn't have such a query.
$claimprocess = Employee::find()
->where("employee_id = 'E1004' and importcompany_id = 1")
->andwhere(" status != 'Deleted' and relationship = 'Self'")
->all();
You need to pass the value correctly , as if now you are not passing the value correctly , hence Yii is not generating Sql query correctly. You can pass second parameter to to where clause
$claimprocess = Employee::find()
->where("employee_id = ':employee_id' and importcompany_id = 1" , array(':employee_id'=>'E1004'))
->andwhere(" status != 'Deleted' and relationship = 'Self'")
->all();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.