[英]Check if a specific row exists regarding its value
I want to check if a string exists in a row in a specific table, i have had no luck in doing this but i was able to gain an understanding on how $query->num_rows();
我想检查一个字符串是否存在于特定表中的一行中,我没有运气这样做但我能够理解
$query->num_rows();
works and i thought i would have to do something like. 工作,我认为我将不得不做类似的事情。
The code i tried below i thought will check if the d009 value exists in the dept_no row and if their are no rows with the value d009 then it should produce an error message. 我想在下面尝试的代码将检查dept_no行中是否存在d009值,如果它们没有值为d009的行,那么它应该产生错误消息。
When i run the code it does not echo any message 当我运行代码时,它不会回显任何消息
$this->db->where('dept_no', 'd009');
$query = $this->db->get('dept_manager');
if($query->num_rows()==0)
{
echo "true";
}
else
{
echo "false";
}
dept_manager table dept_manager表
d009 a
d008 b
d007 c
I think if.. else
should be opposite of what you have specified 我想
if.. else
应该与你指定的相反
if($query->num_rows()==0)
{
echo "false";
}
else
{
echo "true";
}
I mean if num_rows() returns zero rows means value not present in the row.... 我的意思是如果num_rows()返回零行意味着行中不存在的值....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.