MediaSearch_Model_DbTable
[ class tree: MediaSearch_Model_DbTable ] [ index: MediaSearch_Model_DbTable ] [ all elements ]

Source for file KeyWord.php

Documentation is available at KeyWord.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     MediaSearch_Model_DbTable
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.  * KeyWord table database access object.
  23.  *
  24.  * @abstract
  25.  * @category   MediaSearch
  26.  * @package    MediaSearch_Model_DbTable
  27.  * @copyright  Copyright (c) 2009 Sven Strittmatter
  28.  */
  29.     /**
  30.      * Sets the database name to KeyWord.
  31.      *
  32.      * @see Zend_Db_Table_Abstract::__construct()
  33.      *
  34.      * @access public
  35.      * @param array $config 
  36.      */
  37.     public function __construct($config array()) {
  38.         $this->_name  'KeyWord';
  39.         parent::__construct($config);
  40.     }
  41.  
  42.     /**
  43.      * Finds rows by multiple keywords.
  44.      *
  45.      * @access public
  46.      * @param array $keywords 
  47.      * @return array 
  48.      */
  49.     public function findByKeyWords(array $keywords{
  50.         $sql  "SELECT * FROM " $this->_name " ";
  51.         $sql .= "WHERE ";
  52.  
  53.         $count count($keywords);
  54.  
  55.         for ($i 0$i $count$i++{
  56.             $sql .= "keyWord LIKE '{$keywords[$i]}";
  57.  
  58.             if ($i < $count - 1) {
  59.                 $sql .= ' OR ';
  60.             }
  61.         }
  62.  
  63.         <a href="../MediaSearch/MediaSearch_Log.html">MediaSearch_Log</a>::info('Doing SQL: ' . $sql);
  64.  
  65.         $adapter   = $this->getAdapter();
  66.         $statement = $adapter->query($sql);
  67.         $statement->execute();
  68.         
  69.         return $statement->fetchAll();
  70.     }

Documentation generated on Mon, 17 Aug 2009 14:53:20 +0200 by phpDocumentor 1.4.2