code: protected function acquireLock($name, $timeout = 0)
      {
          $lockStatus = null;
  
          // clean vars before using
          $releaseOnCommit = $this->releaseOnCommit ? 'TRUE' : 'FALSE';
          $timeout = abs((int) $timeout);
  
          // inside pl/sql scopes pdo binding not working correctly :(
          $this->db->useMaster(function ($db) use ($name, $timeout, $releaseOnCommit, &$lockStatus) {
              /** @var \yii\db\Connection $db */
              $db->createCommand(
                  'DECLARE
      handle VARCHAR2(128);
  BEGIN
      DBMS_LOCK.ALLOCATE_UNIQUE(:name, handle);
      :lockStatus := DBMS_LOCK.REQUEST(handle, DBMS_LOCK.' . $this->lockMode . ', ' . $timeout . ', ' . $releaseOnCommit . ');
  END;',
                  [':name' => $name]
              )
              ->bindParam(':lockStatus', $lockStatus, PDO::PARAM_INT, 1)
              ->execute();
          });
  
          return $lockStatus === 0 || $lockStatus === '0';
      }
docs: Acquires lock by given name.
  @see http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_lock.htm
  @param string $name of the lock to be acquired.
  @param int $timeout time (in seconds) to wait for lock to become released.
  @return bool acquiring result.