Home  >  Article  >  Backend Development  >  When querying data with phalcon orm, if the field does not exist, will the condition be ignored?

When querying data with phalcon orm, if the field does not exist, will the condition be ignored?

WBOY
WBOYOriginal
2016-08-04 09:22:111386browse

phalcon+mongo, mongo's fields are automatically created when adding data, so when querying, non-existent fields may be used as query conditions. But at this time, phalcon orm will ignore the conditions and return irrelevant Other record lines. How to solve this problem better?

<code>$memberVercode = \Model\MemberVercode::findFirst(array(
    array('telphone'    =>  $telphone),
));
if ($memberVercode/*这个变量怎么判断比较好,即使telphone字段不存在,他依然返回一个纪录对象*/) {
    //如果存在,则更新操作
} else {
    //添加操作
}</code>

Reply content:

phalcon+mongo, mongo's fields are automatically created when adding data, so when querying, non-existent fields may be used as query conditions. But at this time, phalcon orm will ignore the conditions and return irrelevant Other record lines. What is the best way to solve this problem?

<code>$memberVercode = \Model\MemberVercode::findFirst(array(
    array('telphone'    =>  $telphone),
));
if ($memberVercode/*这个变量怎么判断比较好,即使telphone字段不存在,他依然返回一个纪录对象*/) {
    //如果存在,则更新操作
} else {
    //添加操作
}</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn