Yii Framework Forum: Base table or view not found: 1146 Table - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Base table or view not found: 1146 Table unexpected behaviour

#1 User is offline   petervandeput 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-June 17

Posted 14 November 2017 - 03:54 PM

Hi Guys,
I've a very weird situation and can use your help.
In console application building query like this

  $query = (new \yii\db\Query());
            $query->select(['facility_id','shop_id','product_name','product_category_name','received_from_facility_name','unit_of_measure','cast(sum( quantity) as decimal(20,5))  as quantity'])
                ->from('vw_product_total_inventory')
                ->where('facility_id = :facility_id')
                ->addParams([':facility_id'=> $facility['id']])
                ->groupBy([
                    'facility_id',
                    'shop_id',
                    'product_name',
                    'product_id',
                    'product_category_name',
                    'received_from_facility_name',
                    'unit_of_measure']);

            $products = $query->all();


runs perfect on local system, but when i deploy to test server i receive this error

Exception 'yii\db\Exception' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'briteside-wp.vw_product_total_inventory' doesn't exist
The SQL being executed was: SELECT `facility_id`, `shop_id`, `product_name`, `product_category_name`, `received_from_facility_name`, `unit_of_measure`, cast(sum( quantity) as decimal(20,5))  as quantity FROM `vw_product_total_inventory` WHERE facility_id = '1' GROUP BY `facility_id`, `shop_id`, `product_name`, `product_id`, `product_category_name`, `received_from_facility_name`, `unit_of_measure`'


100% verified that the vw_product_total_inventory exist.

This is not a table but a view

All help highly appreciated

Peter
0

#2 User is offline   umneeq 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 10-October 11
  • Location:Russia

Posted 14 November 2017 - 04:10 PM

Maybe because a hyphen in db name?
0

#3 User is offline   petervandeput 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-June 17

Posted 14 November 2017 - 04:13 PM

running exact same SQL as in error message works like a charm

SELECT `facility_id`, `shop_id`, `product_name`, `product_category_name`, `received_from_facility_name`, `unit_of_measure`, cast(sum( quantity) as decimal(20,5)) as quantity FROM `vw_product_total_inventory` WHERE facility_id = '1' GROUP BY `facility_id`, `shop_id`, `product_name`, `product_id`, `product_category_name`, `received_from_facility_name`, `unit_of_measure`

0

#4 User is offline   petervandeput 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 03-June 17

Posted 14 November 2017 - 04:14 PM

i have more views and they have the same problem. on local MYSQL it all works great on test server they all give this error.
0

#5 User is offline   umneeq 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 10-October 11
  • Location:Russia

Posted 14 November 2017 - 05:13 PM

Hmm. Try to recreate your views.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users