Skip to content

Instantly share code, notes, and snippets.

@ahuggins
Created February 2, 2017 18:14
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 ahuggins/0a56a9881849214f34388bd13fb610f7 to your computer and use it in GitHub Desktop.
Save ahuggins/0a56a9881849214f34388bd13fb610f7 to your computer and use it in GitHub Desktop.
<?php
// Before
public function getIDsForClient()
{
$sql = "SELECT DISTINCT FilingID FROM Snapshot1094C WHERE ClientID = ?";
$params = [$this->clientID];
$stmt = sqlsrv_query($this->mssqli, $sql, $params);
$ids = [];
while ( $row = sqlsrv_fetch_array ( $stmt, SQLSRV_FETCH_ASSOC ) ) {
$ids[] = $row['FilingID'];
}
return $ids;
}
// After
public function getIDsForClient()
{
return Snapshot1094C::where('ClientID', $this->clientID)
->select('FilingID')
->distinct('FilingID')
->get()
->pluck('FilingID')
->toArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment