$ composer require germania-kg/itemcodes
Make sure the itemcodes table exists; see Database section.
Setup the MySQL table itemcodes as described in sql/itemcodes.sql.txt
.
Rename the table if needed.
<?php
use Germania\Nav\ItemCodes\ItemCode;
$itemcode = new ItemCode;
$itemcode->setCode("COD")->setName("The Code Name");
This action class requires at least a PDO handle an a table name to work with. A PSR-3 Logger is optional.
<?php
use Germania\Nav\ItemCodes\Actions\InsertOrUpdateItemCode;
// Setup ingredients
$pdo = new \PDO( ... );
$table = "my_itemcodes";
// Optional PSR-3 Logger
$logger = ...
$inserter = new InsertOrUpdateItemCode( $pdo, $table);
$inserter = new InsertOrUpdateItemCode( $pdo, $table, $logger);
// Both are equal:
$result = $insert_or_update( $itemcode );
$result = $insert_or_update->execute( $itemcode );
// $result is 1 when ItemCode has been INSERTed,
// and 2, when REPLACEd
See issues list.
$ git clone https://github.com/GermaniaKG/ItemCodes.git
$ cd ItemCodes
$ composer install
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test
# or
$ vendor/bin/phpunit