Skip to content

Instantly share code, notes, and snippets.

@rccc
Created February 7, 2023 10:31
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 rccc/bfd43032a663f082811f0d3974a4a35e to your computer and use it in GitHub Desktop.
Save rccc/bfd43032a663f082811f0d3974a4a35e to your computer and use it in GitHub Desktop.
<?php
namespace App\Model;
use Doctrine\DBAL\Connection;
class AbstractModel
{
/**
* @var Connection
*/
protected $conn;
/**
* @param Connection $connection
*
* @throws \Exception
*/
public function __construct(Connection $connection = null)
{
if ($connection) {
$this->conn = $connection;
}
}
}
<?php
namespace App\Model;
class PeptideModel extends AbstractModel
{
public function findByProjectGroupByChrompatoPeak(int $project_id)
{
$data = [];
$sql = "SELECT mf.chromato_peak_id, cpp.peptide_id, cpp.best_candidate, p.inchikey
FROM chromato_peak_peptide cpp
JOIN mass_final mf on mf.id=cpp.mass_final_id
join peptide p on p.id=cpp.peptide_id
WHERE cpp.gains_project_id=:id"
;
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('id', $project_id);
$resultset = $stmt->executeQuery();
foreach ($resultset->fetchAllAssociative() as $row) {
$data[array_shift($row)][] = $row;
}
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment