Skip to content

Instantly share code, notes, and snippets.

@mitaken
Created February 24, 2012 11:52
Show Gist options
  • Select an option

  • Save mitaken/1900523 to your computer and use it in GitHub Desktop.

Select an option

Save mitaken/1900523 to your computer and use it in GitHub Desktop.
<?php
class Model_Search
{
protected $_word;
protected $_target = null;
protected $_order = null;
protected $_hash = null;
protected $_min = null;
protected $_max = null;
public function __construct($word)
{
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringTrim());
$filter->addFilter(new Zend_Filter_StripNewlines());
$filter->addFilter(new Zend_Filter_PregReplace('/\p{Z}+/', ' '));
$this->_word = $filter->filter($word);
}
public function getWord()
{
return $this->_word;
}
public function setTarget($target)
{
$this->_target = $target;
return $this;
}
public function setOrder($order)
{
$this->_order = $order;
return $this;
}
public function setMinSize($size)
{
if (ctype_digit((string)$size)) {
$this->_min = $size;
}
return $this;
}
public function setMaxSize($size)
{
if (ctype_digit((string)$size)) {
$this->_max = $size;
}
return $this;
}
public function limitHash(array $hash)
{
$this->_hash = $hash;
return $this;
}
public function run()
{
if (!is_null($this->_min) && !is_null($this->_max) && $this->_min > $this->_max) {
throw new Exception('最小サイズが最大サイズより小さいです');
}
$db = new Database('search');
$select = $db->select();
// hogehoge
return $select;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment