Ajillion PHP-MySQLi-Database-Class Update command

2019-02-26 13:44发布

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.

标签: php class mysqli
1条回答
够拽才男人
2楼-- · 2019-02-26 14:24

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.

查看更多
登录 后发表回答