Base table or view not found: 1146 Table

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

Maybe because a hyphen in db name?

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`



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.

Hmm. Try to recreate your views.