phalcon/cphalcon · error · Phalcon\DataMapper\Pdo\Exception\UnknownDriverMethod
Class '{className}' does not have a method '{name}'
Error message
Class '{className}' does not have a method '{name}' What it means
The connection classes forward unknown method calls through __call() to the underlying \PDO instance. If method_exists() on the PDO object is false, UnknownDriverMethod is thrown: you called a method that is neither defined on the connection class itself nor a real PDO method.
Source
Thrown at phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep:88
*
* @param string $name
* @param array $arguments
*
* @return mixed
* @throws BadMethodCallException
*/
public function __call(var name, array arguments)
{
var className, message;
this->connect();
if !method_exists(this->pdo, name) {
let className = get_class(this),
message = "Class '" . className
. "' does not have a method '" . name . "'";
throw new UnknownDriverMethod(message);
}
return call_user_func_array(
[
this->pdo,
name
],
arguments
);
}
/**
* Begins a transaction. If the profiler is enabled, the operation will
* be recorded.
*
* @return bool
*/
public function beginTransaction() -> boolView on GitHub (pinned to b7419de9cd)
Solutions
- Use the connection's own fetch* helpers (fetchOne, fetchAll, etc.) or query()/prepare() and call statement methods on the returned PDOStatement
- Check the PHP PDO method list — only PDO methods can be forwarded
- Fix typos; the message names the class and the missing method
- No special setup is needed — the connection connects automatically before forwarding valid calls
Example fix
// before
$user = $connection->fetchObject('User'); // not a Connection or PDO method
// after
$stmt = $connection->query('SELECT * FROM users WHERE id = 1');
$user = $stmt->fetchObject('User'); Defensive patterns
Strategy: validation
Validate before calling
$method = 'fetchObject';
if (!method_exists($connection, $method) && !method_exists(\PDO::class, $method)) {
throw new BadMethodCallException(
get_class($connection) . " has no method '{$method}' (and PDO does not either)"
);
}
return $connection->{$method}(...$args); Try / catch
use Phalcon\DataMapper\Pdo\Exception\UnknownDriverMethod;
try {
$result = $connection->{$name}(...$args);
} catch (UnknownDriverMethod $e) {
throw new BadMethodCallException('Invalid DB call: ' . $e->getMessage(), 0, $e);
} Prevention
- Call statement methods (fetchObject, execute, bind*) on the PDOStatement, not on the connection
- Use the connection's fetch* helpers for reading data instead of raw PDO forwarding
- Avoid dynamic method dispatch on the connection unless you validate against PDO's method list first
When it happens
Trigger: Calling PDOStatement-level methods on the connection (fetchObject, execute, bindParam) instead of on the statement; habits from other DB libraries (Doctrine DBAL, mysqli) like ->executeQuery(); typo'd method names (->querry()); helper methods you expected the wrapper to provide.
Common situations: Mixing API styles when migrating from another DBAL; calling data-access helpers that live on the statement, not the connection; stale method names after upgrading.
Related errors
- Driver not supported [{driver}]
- Cannot disconnect a Decorated connection instance
- Connection not found: {type}:{requested}
- Operation cancelled by a listener of '{eventName}'
- Invalid bind parameter (1)
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/302d09ced41bd310.
Report an issue: GitHub.