We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model without a source

I have a phalcon app on my localhost that uses version 1.3.1 and I also have version 1.3.2 on a remote server. On my localhost version I have declared some models that don't have an associated database table and these work fine, I use them as custom classes that aggregate various other models. As soon as they are uploaded to the remote server on 1.3.2 I get error messages about the associated table not existing though. I've tried setting the getSource method to return '' or null but this doesn't work either. Am I missing something here? How should I go about creating a class that doesn't have an associated table?

Thanks



33.8k

My question is: why you would go creating a inexistent model? What do you have in mind to do with it? (just curiosity)



12.2k

I've got a User object that doesn't exist as a table, but it can have a number of resources related to it that do have tables. I define these relationships in the model still and I can retrieve the extra data. I think a lot of what's going on is that I developed on Windows on Xampp but I've deployed to Linux as now I've got a load of issues to do with the Case of my controllers! Windows is a lot more forgiving but this will teach me not to develop on a different platform that I'm deploying to



33.8k

Oh, didn't know about that User object. Anyways, I've heard that Phalcon on Windows have some fails (not sure at all); maybe that can be the issue (apart from the develop/deploying OS).



12.2k

I think it might just be how the servers are configured to handle errors. The Linux distro is less forgiving. The User object isn't built in, it's just something I've created. I use a 3rd party auth system and I don't need to store the data in my DB, hence this fake User model I created

How about creating a dummy table (without any columns)? Then try setting the getSource method to return 'thedummytable'.



12.2k

Yeah I did end up doing that, just weird that it worked on Windows, as I say I think it might be my apache/php config when it comes to handling errors is different between the environments as my linux distro must be set to stop the whole app working

Dealing with DB procedures to read/write models data, I had alike issue. Try this https://docs.phalcon.io/bg/3.2/db-models-metadata#strategies-manual