2017 © Pedro Peláez
 

library basedbmodel

Nette database utility

image

xruff/basedbmodel

Nette database utility

  • Wednesday, February 28, 2018
  • by xruff
  • Repository
  • 2 Watchers
  • 0 Stars
  • 386 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Nette database utility

Requirements

Package requires PHP 5.6 or higher, (*1)

Installation

The best way to install XRuff/BaseDbModel is using Composer:, (*2)

$ composer require xruff/basedbmodel

Short Documentation

UsersRepository for handling database table users. You should use Repository suffix after table name., (*3)


namespace MyModels; use XRuff\App\Model\BaseDbModel; class UsersRepository extends BaseDbModel { // no implementation needed }

If for some reason you can not use the table name or word Repository in class name, follow these steps:, (*4)


namespace MyModels; use Nette\Database\Context; use XRuff\App\Model\BaseDbModel; class MyAnyNameRepo extends BaseDbModel { public function __construct(Context $db) { parent::__construct($db, 'my_db_able_name'); } }

Using model in presenter (or anywhere else):, (*5)

use Nette;
use MyModels\UsersRepository;

class MyUsersPresenter extends Nette\Application\UI\Presenter
{
    /** @var UsersRepository $usersModel */
    public $usersModel;

    public function __construct(
        UsersRepository $usersModel
    ) {
        $this->usersModel = $usersModel;
    }

    public function actionDefault()
    {
        // returns Nette\Database\Table\ActiveRow
        // with first user with name John in table users
        $this->usersModel->getOneBy(['name' => 'John']);

        // or
        // set name as Joe for user with id 5 in table users
        // and returns Nette\Database\Table\ActiveRow with updated values
        $this->usersModel->save(['id' => 5, 'name' => 'Joe']);

        // or add new user with name Jane
        // and returns Nette\Database\Table\ActiveRow with just added row
        $this->usersModel->save(['name' => 'Jane']);

        // or some another method inherited from BaseDbModel
    }
}

Repository https://github.com/XRuff/BaseDbModel., (*6)

The Versions

28/02 2018

dev-master

9999999-dev

Nette database utility

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by Pavel Lauko

component analytics google nette ga

28/02 2018

v2.0.1

2.0.1.0

Nette database utility

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by Pavel Lauko

component analytics google nette ga

14/02 2018

v2.0.0

2.0.0.0

Nette database utility

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by Pavel Lauko

component analytics google nette ga

28/04 2017

v1.0.1

1.0.1.0

Nette database utility

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by Pavel Lauko

component analytics google nette ga

28/04 2017

1.0.0

1.0.0.0

Nette database utility

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

by Pavel Lauko

component analytics google nette ga