PHP code example of ucscode / pairs

1. Go to this page and download the library: Download ucscode/pairs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ucscode / pairs example snippets


use Ucscode\Pairs\Pairs;

// Include the necessary files and create a mysqli connection
$mysqli = new mysqli("host", "username", "password", "database");

// Initialize the Pairs class
$pairs = new Pairs($mysqli, 'tablename');

$pairs->set('car', 'toyota', 2);

$value = $pairs->get('car', 2);

$value = $pairs->get('car', 2, true);

$pairs->remove('car', 2);

$allPairs = $pairs->getSequence();

$pairsByReference = $pairs->getSequence(2);

$pairsByKeyPattern = $pairs->getSequence(2, 'user-%');

$foreignConstraint = new ForeignConstraint('parentTableName');
$foreignConstraint->describePrimaryKeyUnsigned(true);
$foreignConstraint->describePrimaryKeyNullable(false);
$foreignConstraint->describePrimaryKeyColumnName('id');
$pairs->setForeignConstraint($foreignConstraint);