Skip to content

Commit

Permalink
Nevermind, publish the correct file this time for getting the pdo and…
Browse files Browse the repository at this point in the history
… reading a single row
  • Loading branch information
Alex Franzelin committed Jun 29, 2022
1 parent 8740b54 commit e1b6ff3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Pixxel/DBAL.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public function __construct($username, $password, $database, $host = 'localhost'
}
}

/**
* Get the raw pdo object
* @return object
*/
public function getPdo()
{
return $this->pdo;
}

/**
* Perform a query and return true or false, depending on successful or not
* @param string $query
Expand Down Expand Up @@ -88,6 +97,19 @@ public function read($query, $parameters = [])
return $return;
}

/**
* Perform a select query and transform result into a php-object (return the first row only)
* @param string $query
* @param array $parameters
* @return object|bool
*/
public function readSingle($query, $parameters = []): object|bool
{
$result = $this->read($query, $parameters);

return !empty($result) ? $result[0] : false;
}

/**
* Get the last inserted id or false if nothing is returned
* @return int|bool
Expand Down

0 comments on commit e1b6ff3

Please sign in to comment.