Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Model can not see table when save() but see when find()

Hey guys! It's me)

A have a code:

$lead = OfficeStats::findFirst([
        'partner = 1 and order_id = ?0',
        'bind' => [$orderId]
]);
echo $lead->id; // 5 (it's really)
$lead->status_text = 'approved';
if($lead->save()) { // Exception: Table '' doesn't exist in database when dumping meta-data for App\Models\OfficeStats
    // ...
}

Why exception table "" ?

OfficeStats.php:

<?php

    /** 
    *   Статистика по заказам
    */

    namespace App\Models;

    use Phalcon\Mvc\Model;

    class OfficeStats extends Model {

        public function initialize() {

            $this->setSource('office_stats'); 

        }

    }

The first time in 3 years of working with a phalcon I encounter such behavior.



9.3k
Accepted
answer

does this work?

   public function getSource()
    {
        return 'office_stats';
    }

Yes, it helped. but I'm wondering what's wrong with my version, which worked for centuries.

edited Sep '17

Have you upgraded something on your stack just recently?

Phalcon\Mvc\Model\Manager in services container, how does it look like?

 *
 * This components controls the initialization of models, keeping record of relations
 * between the different models of the application.
 *
 * A ModelsManager is injected to a model via a Dependency Injector/Services Container such as Phalcon\Di.