Skip to content

_log_query method raises a warning when query contains "%" #57

@kaemu

Description

@kaemu

Issue

When logging is on:

ORM::configure('logging', true);

Queries containing the "%":

$many = Model::factory('user')->where("active",1)->where_raw('username like "ben%"')->find_many();

Raise PHP warning:

Warning: vsprintf() : Too few arguments in idiorm.php on line 267

Because % must be escaped in the query for vsprintf.

Fix

In idiorm.php, line 264:

$query = str_replace("?", "%s", $query);

should be:

$query = str_replace("?", "%s", str_replace("%","%%",$query));

This fixes the problem for the "%" chars.

Second issue

The problem remains with the "?" char inside the query:

$many = Model::factory('book')->where("active",1)->where_raw('comments like "has been released?%"')->find_many();

vsprintf raises the same error.

— Ben

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions