Created
November 28, 2012 17:01
-
-
Save markbalt/4162541 to your computer and use it in GitHub Desktop.
Run SQL query using Propel PDO Connection
This file contains 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
/** | |
* Get available reserved cabinets not in this project for this customer | |
* | |
* @return array | |
*/ | |
public function getReservedCabinetChoices() | |
{ | |
$id = $this->getId(); | |
$con = Propel::getConnection(); | |
$arr = array(); | |
// include cabinets from this project | |
$sql = "SELECT | |
pc.id, | |
c.`name` | |
FROM | |
cabinet c | |
JOIN `row` r ON c.row_id = r.id | |
LEFT JOIN project_cabinet pc ON pc.cabinet_id = c.id | |
LEFT JOIN project p ON p.id = pc.project_id | |
WHERE pc.project_id <> ".$this->getId()." AND pc.is_reserved = 1 AND p.customer_id = ".$this->getCustomerId()." AND r.facility_id = ".$this->getFacilityId()." ORDER BY r.`order`, c.`order`"; | |
$stmt = $con->prepare($sql); | |
$stmt->execute(); | |
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $up) { | |
$arr[$up['id']] = $up['name']; | |
} | |
$stmt = null; | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment