PDO - CountRow - 错误::非对象

I have a little problem.

$query = $connection->prepare("SELECT * FROM users WHERE username = ? OR mail = ?");
$query = $query->execute(array($username, $mail));
echo $query;
$rows = $query->fetchALL(PDO::FETCH_COLUMN, 0);
$numrows = count($rows);

I get this: Fatal error: Call to a member function fetchALL() on a non-object! Any help please.

EDIT1:

This is working now, but SQL is not execute.

$query = $connection->prepare("SELECT * FROM users WHERE username = ? OR mail = ?");
$result = $query->execute(array($username, $mail));
$count = $query->rowCount();
if ($count == 0) {
//
$query = $connection->prepare("INSERT INTO users(username,password,mail) VALUES (?,?,?)");
$query = $query->execute(array($username, $password, $mail));
//somewhere is mistake :( 

EDIT2:

Everything is ok... My structure in db was username, password and email not mail :)

You are renaming $query. Change $query = $query->execute(... to $execute = $query->execute(...

Then $rows = $query->fetchAll(...

try the following code

$query = $connection->prepare("SELECT * FROM users WHERE username = ? OR mail = ?");
         $query->execute(array($username, $mail));

         $count = $query->rowCount();
         $rows = $query->fetchALL(PDO::FETCH_COLUMN, 0);

You are reassigning the $query variable Try

    $query = $connection->prepare("SELECT * FROM users WHERE username = ? OR email = ?");
    $result = $query->execute(array($username, $mail));
    $rows = $result->fetchALL(PDO::FETCH_COLUMN, 0);
    $numrows = count($rows);

For other question try

   $query = $connection->prepare("SELECT * FROM users WHERE username = ? OR mail = ?");
   $result = $query->execute(array($username, $mail));
   $count = $query->rowCount();
   if ($count == 0) {

    $query = $connection->prepare("INSERT INTO users(username,password,email) VALUES             (:username, :password, :mail)";)
    $query->execute(array(':username'=> $username,
                             ':password'=> $password,
                              ':email'= $mail));

 }