我正在使用Codeigniter Active Record Class在单个Model函数中存储从查询多个表返回的行数,我的模型函数看起来像 -
模型 -
function my_model_function($param1)
{
$step_passed = array();
$step_passed['step1'] = 'pass';
$query_table1 = $this->db->where('param1', $param1)
->get('table1');
if($query_table1->num_rows() > 0)
{
$step_passed['step2'] = 'pass';
}
$query_table2 = $this->db->where('param1', $param1)
->get('table2');
if($query_table2->num_rows()> 0)
{
$step_passed['step3'] == 'pass';
}
return $step_passed;
}
在我看来,就像我打印这个结果一样 -
Array([step1] => pass [step2] => pass)
但是我的预期结果应该是 -
Array([step1] => pass [step2] => pass [step3] => pass)
我确认所有表[table1,table2,table3]都有与param1匹配的数据,但我没有看到表3的结果。
我尝试了什么 -
1.I tried printing the number of rows returned from query_table2 and
it comes as 1 which is greater than 0, and I have no idea why my if statement is not lighting up at this point
2. I tried entering test key value pair inside my mode function like -
$step_passed['test_data'] = 'test';
我将结果视为 -
Array([step1] => pass [step2] => pass [test] => test)
我很难进入我的if($ query_table2-> num_rows()> 0)语句,它真的返回1,你能帮我解决一下吗?
答案 0 :(得分:2)
@Siva
你写过
$step_passed['step3'] == 'pass';
此处您使用了==
运算符,因此请将其替换为'='
。所以它应该像下面的
$step_passed['step3'] = 'pass';