Created
February 7, 2023 10:31
-
-
Save rccc/bfd43032a663f082811f0d3974a4a35e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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