Ajillion PHP-MySQLi-Database-Class Update命令 [英] Ajillion PHP-MySQLi-Database-Class Update command

查看:192
本文介绍了Ajillion PHP-MySQLi-Database-Class Update命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Ajillion制作的MySQLi类: https://github.com/ajillion / PHP-MySQLi-Database-Class



我想执行以下命令:

  $ command =UPDATE sessions SET active = 0 WHERE DATE_ADD(last,INTERVAL life MINUTE)< = now(); 

我不知道如何做这个类。有一种方法,我可以使用该类来管理WHERE语句,尤其是UPDATE命令,因为正常的查询我可以$ mysqli-> rawQuery()命令。



运行rawQuery()上面的命令的问题是,我得到一个


PHP致命错误:调用成员函数fetch_field一个非对象


,因为它试图收集UPDATE命令没有给出的结果。

$ b



换行101

$

$ b b
$ b

  $ this-> _query = filter_var($ query,FILTER_SANITIZE_STRING); 

  $ this-> _query = $ this-> _mysqli-> real_escape_string($ query); 

然后我继续添加

  if(gettype($ meta)==boolean)return $ results; 

在第401行之后



一个更好的方法来做到这一点,但这是我做了,它似乎工作。


Using the MySQLi class made by Ajillion :: https://github.com/ajillion/PHP-MySQLi-Database-Class

I would like to execute the following command

$command = "UPDATE sessions SET active = 0 WHERE DATE_ADD(last, INTERVAL life MINUTE) <= now()";

and I'm not sure how to do it with the class. Is there a way I can manage WHERE statements like this using that class, especially for UPDATE commands since normal queries I can $mysqli->rawQuery() the command.

The problem with running rawQuery() on the command above is that I get a

PHP Fatal error: Call to a member function fetch_field() on a non-object

since it is trying to gather the results that an UPDATE command doesn't give.

解决方案

This has appeared to solve the issue.

change line 101

$this->_query = filter_var($query, FILTER_SANITIZE_STRING);

to

$this->_query = $this->_mysqli->real_escape_string($query);

I then went on to add

if(gettype($meta) == "boolean") return $results;

after line 401

There may be a better way to do this but this is what I did and it seems to work.

这篇关于Ajillion PHP-MySQLi-Database-Class Update命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆