Skip to content

Instantly share code, notes, and snippets.

@dragoonis
Created October 7, 2011 16:51
Show Gist options
  • Save dragoonis/1270772 to your computer and use it in GitHub Desktop.
Save dragoonis/1270772 to your computer and use it in GitHub Desktop.
<?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