public function search() { $methods = get_class_methods($this); $sql = array(); foreach ($methods as $method) { $matches = array(); if (preg_match('/([a-zA-z0-9_]+)_conditions$/', $method, $matches)) { $retrun = call_user_func(array($this, $method)); if (!empty($return)) { $sql[] = NimbleRecord::sanitize($return); } } } $conditions = implode(' ', $sql); return Package::find_all(array('conditions' => $conditions)); }
public function testSanitizeSingleValueManyQ() { $sql = NimbleRecord::sanitize(array('name LIKE ? OR summary LIKE ? OR description LIKE ?', 'foo')); $this->assertEquals("name LIKE 'foo' OR summary LIKE 'foo' OR description LIKE 'foo'", $sql); }