public function rawExec(string $sql, array $params=[]): bool
  {
    $result = false;

    # Sanity check
    if (empty($sql)) {
      return $result;
    }

    # Obtain transaction, unelss already in a transaction
    $autoCommit = $this->beginTransaction();

    # Prepare
    if ($sth = $this->prepare($sql)) {
      # Binds
      foreach ($params as $bind=>$value) {
        $sth->bindValue( ':'.\ltrim($bind,':'), $value);
      }

      # Execute statement
      if ($sth->execute()) {
        $result = $sth->rowCount() > 0;
      }

      # Close cursor
      $sth->closeCursor();
    }

    # If we had a loacl transaction, commit it
    if ($autoCommit) $this->commit();

    return $result;
  }
public function rawExec(string $sql, array $params=[]): bool
  {
    $result = false;

    # Sanity check
    if (empty($sql)) {
      return $result;
    }

    # Obtain transaction, unelss already in a transaction
    $autoCommit = $this->beginTransaction();

    # Prepare
    if ($sth = $this->prepare($sql)) {
      # Binds
      foreach ($params as $bind=>$value) {
        $sth->bindValue( ':'.\ltrim($bind,':'), $value);
      }

      # Execute statement
      if ($sth->execute()) {
        $result = $sth->rowCount() > 0;
      }

      # Close cursor
      $sth->closeCursor();
    }

    # If we had a loacl transaction, commit it
    if ($autoCommit) $this->commit();

    return $result;
  }
public function rawExec ( string $ sql , array $ params = [ ] ) : bool { $ result = false ; # Sanity check if ( empty ( $ sql ) ) { return $ result ; } # Obtain transaction, unelss already in a transaction $ autoCommit = $ this -> beginTransaction ( ) ; # Prepare if ( $ sth = $ this -> prepare ( $ sql ) ) { # Binds foreach ( $ params as $ bind => $ value ) { $ sth -> bindValue ( ':' . \ ltrim ( $ bind , ':' ) , $ value ) ; } # Execute statement if ( $ sth -> execute ( ) ) { $ result = $ sth -> rowCount ( ) > 0 ; } # Close cursor $ sth -> closeCursor ( ) ; } # If we had a loacl transaction, commit it if ( $ autoCommit ) $ this -> commit ( ) ; return $ result ; }
Execute an INSERT, UPDATE or DELETE statement

@param      string  $sql     SQL statement to execute (INSERT, UPDATE,
DELETE ...)
@param      array   $params  Bind params

@return     bool    True if rows affected > 0
Execute an INSERT UPDATE or DELETE statement