PHP Classes

File: src/Exception/MustBeOneDimensionalArray.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   EasyDB   src/Exception/MustBeOneDimensionalArray.php   Download  
File: src/Exception/MustBeOneDimensionalArray.php
Role: Class source
Content type: text/plain
Description: Class source
Class: EasyDB
Simple Database Abstraction Layer around PDO
Author: By
Last change: Refactoring

- Change exceptions to extend the same base class
- Update code style to avoid \\ prefixes (use imports instead)
Date: 1 year ago
Size: 1,213 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\EasyDB\Exception;

use
ParagonIE\Corner\CornerInterface;
use
ParagonIE\Corner\CornerTrait;
use
Throwable;

/**
 * Class MustBeOneDimensionalArray
 * @package ParagonIE\EasyDB\Exception
 */
class MustBeOneDimensionalArray extends EasyDBException
{
    use
CornerTrait;

    public function
__construct(string $message = "", int $code = 0, Throwable $previous = null)
    {
       
parent::__construct($message, $code, $previous);
       
$this->supportLink = 'https://github.com/paragonie/easydb#only-one-dimensional-arrays-are-allowed';
       
$this->helpfulMessage = "Many of the EasyDB methods expect variadic parameters.

Instead of doing something like this:

    \$rows = \$db->run(\$query, \$params);

You want to do something like this:

    \$rows = \$db->run(\$query, ...\$params);
    \$rows = \$db->safeQuery(\$query, \$params);

A list of variadic methods and their array-expecting equivalents is as follows:
 
   * col() -> column(): array
   * cell() -> single(): scalar
   * first() -> column(): array
   * exists() -> single(): bool
   * q() -> safeQuery(): array[]
   * row() -> safeQuery(): array
   * run() -> safeQuery(): array[]
"
;
    }
}