Skip to content

Instantly share code, notes, and snippets.

@DenisMir
Last active April 27, 2016 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DenisMir/63064fc49ff9c5d272a07c79f56dd618 to your computer and use it in GitHub Desktop.
Save DenisMir/63064fc49ff9c5d272a07c79f56dd618 to your computer and use it in GitHub Desktop.
<?php
public function findByUid()
{
$uid = 1234;
$fields = '*';
$table = 'some_table';
$where = 'some_table.uid = :uid';
$params = array(
':uid' => $uid
);
$this->db->store_lastBuiltQuery = 1;
/** @var PreparedStatement $preparedQuery */
$preparedQuery = $this->db->prepare_SELECTquery($fields, $table, $where);
$preparedQuery->execute($params);
$this->logger->debug('Found rows: ' . $preparedQuery->rowCount());
$this->logger->debug('Last build query: ' . $this->db->debug_lastBuiltQuery);
if ($preparedQuery->rowCount() > 0) {
$row = $preparedQuery->fetch();
$this->logger->debug('Result found');
} else {
$this->logger->debug('No result found. Returning null.');
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment