@param $id
@param string|null $key

@return int
194638
protected function deleteByKey($id, string $key = null): int
    {
        $key = empty($key) ? $this->repository->getModel()->getKeyName() : $key;

        $row = 0;

        try {
            $row = $this->queryRelate->whereIn($key, (array) $id)->getQuery()->delete();
        } catch (\RuntimeException $exception) {
            throw new ResourceDeleteException($exception->getMessage(), $exception->getCode(), $exception);
        } finally {
            $this->resetQueryRelate();
        }

        return $row;
    }
73341
public function count($key = null)
	{
		if (is_null($key)) {
			return count($this->params);
		}
		return count($this->getArray($key));
	}
652370
public function getInt($key)
    {
        try {
            $result = $this->get(self::INT, $key);
            if (!settype($result, 'integer')) {
                return 0;
            }
        } catch (\Exception $e) {
            return 0;
        }
        return $result;
    }
529228
@Override
    public int getInt(@NonNull String key) {
        if (key == null) { throw new IllegalArgumentException("key cannot be null."); }

        final int index = indexForColumnName(key);
        return index >= 0 ? getInt(index) : 0;
    }
620295
public function read($id = null)
    {
        return ($id != null)
            ? $this->findByID($id)
            : $this->newModel();
    }
1014575
private function load($id = null)
    {

        $this->initialize();
        $this->id = $id;
        return $this->getDataConnector()->loadContext($this);

    }
131978
public function read($id)
    {
        if (!$data = $this->getCache()->load($this->normalizeId($id))) {
            return null;
        }

        return $data;
    }
65625
public function remove_shortcut($id): ?int
  {
    if ( \bbn\str::is_uid($id) ){
      return $this->pref->delete_bit($id);
    }
    return null;
  }
338148
public function getLastPage($id = null)
    {
        $totalItems = ($this->getTotalItems($id) > 0) ? $this->getTotalItems($id) : 1;
        return (int)ceil($totalItems / $this->getItemsPerPage($id));
    }
147288
function calcular_total($id = null){
		if (!empty($id)) $this->id = $id;

		$subtotal = $this->calcular_subtotal();
		$totalPorcentajeDescuento = $this->calcular_descuentos();

		$conversionDescuento = 1-($totalPorcentajeDescuento/100);

		$total = cqs_round(  $subtotal * $conversionDescuento );

		return $total;
	}
902682
public function first($id = null) {
        if ($id) {
            $this->where($this->connection->getPrimaryKey(), $id);
        }
        $data = $this->get();

        return $data ? $data[0] : [];
    }
892252
public function update($id, $key, $value=null)
     {
         $model =  $this->model->find($id);

         if (is_array($key))
             $model->update($key);
         else
             $model->{$key}= $value;

         $model->save();
     }
941761
public function fetchById($int_key_id)
    {
        $arr_results = $this->fetchByIds([$int_key_id]);
        if(count($arr_results) > 0) {
            return $arr_results[0];
        }
        return null;
    }
240343
public function getNumOfParent($id)
    {
        if ($parents = $this->qb
            ->table($this->table)
            ->select('id')
            ->where('id', $id)
            ->get()) {
            return $parents->count();
        }

        return 0;
    }
994656
public function deleteById($id) : int
    {
        $sql = 'DELETE FROM `' . $this->table . '` WHERE ';

        // Assign ids
        if (is_array($id)) {
            $i = 0;
            foreach ($id as $_id) {
                if ($i === 0) {
                    $sql .= ' id=:id' . $i;
                } else {
                    $sql .= ' OR id=:id' . $i;
                }
                $i++;
            }
            $query = $this->pdo->prepare($sql);
            for ($j = 0; $j < 0; $j++) {
                $query->bindParam(':id' . $j, $id[$j]);
            }
        } else {
            $sql .= 'id=:id';
            $query = $this->pdo->prepare($sql);
            $query->bindParam(':id', $id);
        }

        $query->execute();

        return $query->rowCount();
    }
1133581
public function getById($id)
    {       
        if (!is_null($this->_table) && !is_null($id)) {
            $this->_sql = "SELECT * FROM $this->_table WHERE id = $id";
            $row = $this->_select($this->_sql);
            return (isset($row[0])) ? $row[0] : null;
        }
    }
425147
public function getModuleById($id)
    {
        $modules = \JModuleHelper::getModules(null);

        $total = count($modules);

        for ($i = 0; $i < $total; $i++)
        {
            if ($modules[$i]->id == $id)
            {
                return $modules[$i];
            }
        }

        return null;
    }