Illuminate\Database\Connection::affectingStatement PHP Метод

affectingStatement() публичный Метод

Run an SQL statement and get the number of rows affected.
public affectingStatement ( string $query, array $bindings = [] ) : integer
$query string
$bindings array
Результат integer
    public function affectingStatement($query, $bindings = [])
    {
        return $this->run($query, $bindings, function ($me, $query, $bindings) {
            if ($me->pretending()) {
                return 0;
            }
            // For update or delete statements, we want to get the number of rows affected
            // by the statement and return that back to the developer. We'll first need
            // to execute the statement and then we'll use PDO to fetch the affected.
            $statement = $me->getPdo()->prepare($query);
            $this->bindValues($statement, $me->prepareBindings($bindings));
            $statement->execute();
            return $statement->rowCount();
        });
    }

Usage Example

Пример #1
0
 public function execute($sql)
 {
     return $this->connection->affectingStatement($sql);
 }