original_string: public function save($table, $data, $id = 'id', $auto_id = true)
      {
          // Update
          if (isset($data[$id]) && $this->getFieldById($table, $id, $this->escape($data[$id]), $id) !== false) {
              try {
                  return $this->updateById($table, $data, $id);
              } catch (\Exception $e) {
                  throw $e;
              }
  
              // Insert
          } else {
              try {
                  if ($auto_id) {
                      unset($data[$id]);
                  }
                  return $this->insertId($table, $data);
              } catch (\Exception $e) {
                  throw $e;
              }
          }
      }
code: public function save($table, $data, $id = 'id', $auto_id = true)
      {
          // Update
          if (isset($data[$id]) && $this->getFieldById($table, $id, $this->escape($data[$id]), $id) !== false) {
              try {
                  return $this->updateById($table, $data, $id);
              } catch (\Exception $e) {
                  throw $e;
              }
  
              // Insert
          } else {
              try {
                  if ($auto_id) {
                      unset($data[$id]);
                  }
                  return $this->insertId($table, $data);
              } catch (\Exception $e) {
                  throw $e;
              }
          }
      }
code_tokens: public function save ( $ table , $ data , $ id = 'id' , $ auto_id = true ) { // Update if ( isset ( $ data [ $ id ] ) && $ this -> getFieldById ( $ table , $ id , $ this -> escape ( $ data [ $ id ] ) , $ id ) !== false ) { try { return $ this -> updateById ( $ table , $ data , $ id ) ; } catch ( \ Exception $ e ) { throw $ e ; } // Insert } else { try { if ( $ auto_id ) { unset ( $ data [ $ id ] ) ; } return $ this -> insertId ( $ table , $ data ) ; } catch ( \ Exception $ e ) { throw $ e ; } } }
docstring: Saving to DB by Id
  existing entry => update, else => insert
  @param $table
  @param $data
  @param string $id
  @param bool $auto_id
  @return mixed|string
  @throws \Exception
docstring_tokens: Saving to DB by Id existing entry = > update else = > insert