示例#1
0
 public function feedItemCount($feedId)
 {
     $db = get_db();
     $select = new Omeka_Db_Select();
     $select->from(array('fiii' => $db->FeedImporterImportedItem), "COUNT(DISTINCT(fiii.id))");
     $select->join(array('fii' => $db->FeedImporterImport), 'fii.id = fiii.import_id', array());
     $select->join(array('fif' => $db->FeedImporterFeed), 'fif.id = fii.feed_id', array());
     $select->where('fif.id = ?');
     //echo $select;
     $feedItemCount = $db->fetchOne($select, array($feedId));
     return $feedItemCount;
 }
 /**
  * 
  * @param unknown_type $params
  * newspaperIds
  * states
  * 
  */
 public function getStats($params = array())
 {
     $select = new Omeka_Db_Select($this->getDb()->getAdapter());
     $db = $this->_db;
     $select->from($db->NewspapersNewspaper, '*');
     $select->join($db->NewspapersIssue, "{$db->NewspapersIssue}.newspaper_id = {$db->NewspapersNewspaper}.id", array());
     $select->join($db->NewspapersFrontPage, "{$db->NewspapersFrontPage}.issue_id = {$db->NewspapersIssue}.id", array(new Zend_Db_Expr("std({$db->NewspapersFrontPage}.columns) as stdColumns"), new Zend_Db_Expr("avg({$db->NewspapersFrontPage}.columns) as avgColumns"), new Zend_Db_Expr("min({$db->NewspapersFrontPage}.columns) as minColumns"), new Zend_Db_Expr("max({$db->NewspapersFrontPage}.columns) as maxColumns"), new Zend_Db_Expr("max({$db->NewspapersFrontPage}.page_height) as maxPageHeight"), new Zend_Db_Expr("min({$db->NewspapersFrontPage}.page_height) as minPageHeight"), new Zend_Db_Expr("avg({$db->NewspapersFrontPage}.page_height) as avgPageHeight"), new Zend_Db_Expr("std({$db->NewspapersFrontPage}.page_height) as stdPageHeight"), new Zend_Db_Expr("max({$db->NewspapersFrontPage}.page_width) as maxPageWidth"), new Zend_Db_Expr("min({$db->NewspapersFrontPage}.page_width) as minPageWidth"), new Zend_Db_Expr("avg({$db->NewspapersFrontPage}.page_width) as avgPageWidth"), new Zend_Db_Expr("std({$db->NewspapersFrontPage}.page_width) as stdPageWidth")));
     if (isset($params['states'])) {
         $select->where("{$db->NewspapersNewspaper}.state IN (?)", $params['states']);
     }
     if (isset($params['newspaperIds'])) {
         $select->where("{$db->NewspapersNewspaper}.id IN (?)", $params['newspaperIds']);
     }
     if (isset($params['columns'])) {
         $select->where("{$db->NewspapersFrontPage}.columns = ?", $params['columns']);
     }
     if (isset($params['columns_greater_than'])) {
         $select->where("{$db->NewspapersFrontPage}.columns > ", $params['columns']);
     }
     if (isset($params['columns_less_than'])) {
         $select->where("{$db->NewspapersFrontPage}.columns < ", $params['columns']);
     }
     //precision is iffy, so include a range
     if (isset($params['width'])) {
         $floor = $params['width'] - 500;
         $ceil = $params['width'] + 500;
         $select->where("{$db->NewspapersFrontPage}.page_width BETWEEN {$floor} AND {$ceil}");
     }
     if (isset($params['height'])) {
         $floor = $params['height'] - 500;
         $ceil = $params['height'] + 500;
         $select->where("{$db->NewspapersFrontPage}.page_height BETWEEN {$floor} AND {$ceil}");
     }
     $result = $this->_db->fetchAll($select);
     return $result[0];
 }
 /**
  * This adds the joins and where clauses to respect an addon's privacy
  * settings.
  *
  * @param Omeka_Db_Select        $select The select object to modify.
  * @param SolrSearch_Addon_Addon $addon  The current addon. You should
  * already know that this addon does have a public flag somewhere in its
  * hierarchy before calling this.
  *
  * @return null
  * @author Eric Rochester <*****@*****.**>
  **/
 private function _addFlag($select, $addon)
 {
     if (!is_null($addon->flag)) {
         $table = $this->db->getTable($addon->table);
         $select->where("`{$table->getTableName()}`.`{$addon->flag}`=1");
     } else {
         if (!is_null($addon->parentAddon)) {
             $parent = $addon->parentAddon;
             $table = $this->db->getTable($addon->table)->getTableName();
             $ptable = $this->db->getTable($parent->table)->getTableName();
             $select->join($ptable, "`{$table}`.`{$addon->parentKey}`=`{$ptable}`.`{$parent->idColumn}`", array());
             $this->_addFlag($select, $parent);
         }
     }
 }