Welcome Guest, Not a member yet? Register   Sign In
WHERE-LIKE and problem for build search-engin in western movie web app
#5

I have a movie catalog and I believe I can help you, but I use CI4. As I only use queries, I believe it is possible for you to adapt them to CI3.
The method of sending the search argument I still use the same as used in CI3:
Code:
<div class="search-container">
<form action="/search/allmedia" class="site-search" method="post" name="site-search">
<input class="site-search-button" name="wdeda" type="submit" />
<input class="site-search-input" name="search" placeholder="Search" tabindex="1" type="search" />
</form>
</div>
I also have a music catalog from the movie catalog so the "form action is 'search/allmedia' where search is the controller and allmedia the method. This code is inserted in a header, used on every page.

Below the search code, I also show the number of results, in the search result. You can search by title, the one used in your country, 'title' and/or by the original title, 'origtitle'; 'terms' is the search argument coming from the form.
PHP Code:
  public function getMovies()
    {
        $request service('request');
        $terms $request->getVar('search');
        $db $this->db;
        $query $db->table('movies')
            ->select('*')
            ->like('title'$terms)
            ->orLike('origtitle'$terms)
            ->orderBy('year''title''desc')
            ->get();

        return $query->getResult();
    

$request is related to CI4

PHP Code:
public function numMovies()
    {
        $request service('request');
        $terms $request->getVar('search');
        $db $this->db;
        $count $db->table('movies');
        $count->like('title'$terms);
        $count->orLike('origtitle'$terms);
        $data $count->countAllResults();

        return $date;
    

As for directors, year, actors, etc. it will depend on how you created it or will you create a table for it. There is another important detail regarding data modeling. In addition to the "movies" table you should also have a "names" table and as the relationship between them is many to many, a third table should be created, relating both.
Reply


Messages In This Thread
RE: WHERE-LIKE and problem for build search-engin in western movie web app - by wdeda - 10-16-2021, 08:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB