Welcome Guest, Not a member yet? Register   Sign In
Relations Module
#16

(This post was last modified: 08-10-2020, 08:55 AM by hungtrinhbds.)

This my test code:
PHP Code:
$schemas service('schemas');
$schemas->draft()->get();
$movieModel = new \Hcv\Imdb\Models\Moviemodel;
$movieModel->where('votes_avg'7);
$movieModel->where('genre.genre_id''action');
$query $movieModel->get();
foreach (
$query->getResult() as $row) {
    echo 
$row->title;

This is Error:
PHP Code:
ErrorException
SQLite3
::query(): Unable to prepare statement1no such columngenre.genre_id 
Database connects OK.
PHP Code:
<?php namespace Hcv\Imdb\Models;

use \
Tatter\Relations\Traits\ModelTrait;

class 
Moviemodel extends \CodeIgniter\Model
{
    use 
ModelTrait;

    protected $table      'movie';
    protected $primaryKey 'movie_id';

    protected $returnType 'Hcv\Imdb\Entities\Movie';
    protected $useSoftDeletes false;

    protected $allowedFields = ['title''link_poster''storyline''rate''releasedate''month''year''budget''grossUSA''gross''genre_id'];

    protected $useTimestamps false;
    protected $createdField  '';
    protected $updatedField  '';
    protected $deletedField  '';

    protected $validationRules    = [
                    'movie_id'    => 'required|is_unique[movi.movie_id]',
            ];
    protected $validationMessages = [];
    protected $skipValidation     false;

    protected $with = ['genre''language''country''company''movie_cast''movie_crew'];

    public function hcvFind($value='')
    {
        # code...
    }

PHP Code:
<?php namespace Hcv\Imdb\Entities;

class 
Movie extends \CodeIgniter\Entity
{
        use \
Tatter\Relations\Traits\EntityTrait;  

        
protected $table      'movie';
        protected 
$primaryKey 'movie_id';
        
        public function 
setGenre_name($genre=[])
        {
                
$this->attributes['genre_name'] = 'genre_name';
                return 
$this;
        }


Reply


Messages In This Thread
Relations Module - by MGatner - 09-24-2019, 08:20 AM
RE: Relations Module - by MGatner - 11-19-2019, 02:27 PM
RE: Relations Module - by nicolasriver - 11-30-2019, 08:01 AM
RE: Relations Module - by MGatner - 12-01-2019, 05:03 AM
RE: Relations Module - by x1250 - 02-17-2020, 08:24 PM
RE: Relations Module - by Basic App - 02-18-2020, 12:18 AM
RE: Relations Module - by MGatner - 02-18-2020, 04:25 AM
RE: Relations Module - by x1250 - 02-18-2020, 11:32 AM
RE: Relations Module - by MGatner - 02-18-2020, 11:36 AM
RE: Relations Module - by Basic App - 02-18-2020, 12:37 PM
RE: Relations Module - by MGatner - 02-20-2020, 04:11 AM
RE: Relations Module - by MGatner - 07-13-2020, 01:28 PM
RE: Relations Module - by hungtrinhbds - 08-09-2020, 08:41 AM
RE: Relations Module - by MGatner - 08-10-2020, 06:24 AM
RE: Relations Module - by hungtrinhbds - 08-10-2020, 08:19 AM
RE: Relations Module - by hungtrinhbds - 08-10-2020, 08:52 AM
RE: Relations Module - by MGatner - 08-11-2020, 04:26 AM
RE: Relations Module - by hungtrinhbds - 08-12-2020, 07:37 AM
RE: Relations Module - by MGatner - 08-14-2020, 02:38 PM
RE: Relations Module - by hungtrinhbds - 08-19-2020, 01:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB