Classes

File content/keyword/AjaxKeywordsAutoCompleteController.class.php

File content/keyword/AjaxKeywordsAutoCompleteController.class.php

 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 
<?php
/**
 * @package     Content
 * @subpackage  Keyword
 * @copyright   &copy; 2005-2019 PHPBoost
 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
 * @author      Kevin MASSY <reidlos@phpboost.com>
 * @version     PHPBoost 5.2 - last update: 2015 07 07
 * @since       PHPBoost 4.0 - 2013 08 28
 * @contributor Julien BRISWALTER <j1.seth@phpboost.com>
*/

class AjaxKeywordsAutoCompleteController extends AbstractController
{
    public function execute(HTTPRequestCustom $request)
    {
        $suggestions = array();

        try {
            $result = PersistenceContext::get_querier()->select("SELECT name, rewrited_name FROM " . DB_TABLE_KEYWORDS . " WHERE name LIKE '" . $request->get_value('value', '') . "%'");

            while($row = $result->fetch())
            {
                $suggestions[] = $row['name'];
            }
            $result->dispose();
        } catch (Exception $e) {
        }

        return new JSONResponse(array('suggestions' => $suggestions));
    }
}
?>