[eluser]ianonyk[/eluser]
Hello everybody,
I'm having a problem with CI with my recent project. Hope you guys could help me out. Thanks alot
Here is my site
iDicts.
Now when I enter a word with a space in it ie "help me". It doesn't return any result. Below is my model and controller.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dictionary_model extends CI_Model {
/**
* Get Data tu dien Anh - Viet (Wordnet 2.0)
*
* @return string
* @author Khoi.Tv + HungNv
**/
function get_def_wordnet($word){
$this->db->where('name', $word);
$query = $this->db->get('wordnet', 1);
$row = $query->result_array();
$def = $row[0]['def'];
if($def){
$def = preg_replace("/\s+/S", " ", $def);
$def = str_replace("n 1:","<span class='wordcat'>NOUN</span>1:",$def);
$def = str_replace("adj 1:","<span class='wordcat'>ADJECTIVE</span>1:",$def);
$def = str_replace("v 1:","<span class='wordcat'>VERB</span>1:",$def);
$def = str_replace("n :","<span class='wordcat'>Noun</span>1:",$def);
$def = str_replace("adj :","<span class='wordcat'>ADJECTIVE</span>1:",$def);
$def = str_replace("v :","<span class='wordcat'>VERB</span>1:",$def);
$pattern = "/\d+:.*?(?=\d+:|$)/";
$replacement = "<span class='meaning'>$0</span>";
$def = preg_replace($pattern, $replacement, $def);
return $def;
} else {
return "";
}
}
}
/* End of file dictionary_model.php */
/* Location: ./application/models/dictionary_model.php */
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dictionary extends CI_Controller {
public function index(){
$this->q("hello");
}
public function q($word="")
{
$this->load->model('dictionary_model');
$data['wordnet'] = $this->dictionary_model->get_def_wordnet($word);
$this->load->view('dictionary_view', $data);
}
}
/* End of file dictionary.php */
/* Location: ./application/controllers/dictionary.php */