Skip to content

Commit

Permalink
Commentary
Browse files Browse the repository at this point in the history
Signed-off-by: pine3ree <[email protected]>
  • Loading branch information
pine3ree committed Oct 5, 2023
1 parent 0da1821 commit 9d5cc59
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
use function reset;
use function sprintf;

/**
* Class Db
*/
class Db
{
/** @var PDO|null */
Expand Down Expand Up @@ -245,15 +242,15 @@ private function initializePDO(): bool
return false;
}

// set attributes if a PDO instance was passed in
// Set attributes if a PDO instance was passed in
if (empty($this->dsn)) {
foreach ($this->options as $attribute => $value) {
$this->pdo->setAttribute($attribute, $value);
}
}

switch ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) {
// set charset for pgsql: since charset is a developer written
// Set charset for pgsql: since charset is a developer written
// configuration value there is no need for escaping
case 'pgsql':
$this->pdo->exec("SET NAMES '{$this->charset}'");
Expand All @@ -279,7 +276,7 @@ public function getDriver(bool $with_pdo = false): DriverInterface
$pdo = $with_pdo ? $this->pdo() : $this->pdo;

if (isset($pdo)) {
// inject and reuse the pdo-less instance, if any, with the active
// Inject and reuse the pdo-less instance, if any, with the active
// pdo connection
if (isset($this->_driver)) {
$this->_driver->setPDO($pdo);
Expand All @@ -297,7 +294,7 @@ public function getDriver(bool $with_pdo = false): DriverInterface
}

$driver_name = explode(':', $this->dsn)[0];
// cache the pdo-less driver instance
// Cache the pdo-less driver instance
$this->_driver = $this->createDriverFromName($driver_name);
return $this->_driver;
}
Expand Down Expand Up @@ -438,12 +435,12 @@ public function insert(string $table = null, array $row_or_rows = null)
return 0;
}

// multiple rows insert: returns int|false
// Multiple rows insert: returns int|false
if (is_array(reset($row_or_rows))) {
return $insert->rows($row_or_rows)->execute();
}

// single row insert: returns bool
// Single row insert: returns bool
$result = $insert->row($row_or_rows, true)->execute();

return $result === false ? false : ($result > 0);
Expand Down

0 comments on commit 9d5cc59

Please sign in to comment.