Created
October 7, 2011 16:51
-
-
Save dragoonis/1270772 to your computer and use it in GitHub Desktop.
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
<?php | |
class APP_Model_CategoryNew { | |
protected $_name = 'category'; | |
protected $_key = 'id'; | |
function __construct() { | |
$ds = new PPI_DataSource(); | |
$this->_handler = $ds->factory('mysql'); | |
} | |
/** | |
* Get all categories for the main Shop Menu Dropdown | |
* | |
* @return array | |
*/ | |
function getShopMenuDropdownItems() { | |
$query = "SELECT * FROM {$this->_name} | |
WHERE supplier = 'pricegrabber' AND level = 'topcat' AND id NOT IN(2731, 2733, 2748) | |
ORDER BY title;"; | |
$stmt = $this->_handler->query($query); | |
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); | |
$stmt->closeCursor(); | |
$this->_handler->close(); | |
return $rows; | |
} | |
/** | |
* Get a specific category by its primary key | |
* | |
* @param integer $catID | |
* @return array | |
*/ | |
function find($catID) { | |
$query = "SELECT * FROM {$this->_name} where {$this->_key} = ?"; | |
$stmt = $this->_handler->prepare($query); | |
$stmt->bindValue(1, $catID); | |
$stmt->execute(); | |
$row = $stmt->fetch(PDO::FETCH_ASSOC); | |
$stmt->closeCursor(); | |
$this->_handler->close(); | |
return $row; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment