Walther Posted November 3, 2022 Share Posted November 3, 2022 (edited) About db managing using capsule I googled around quite deeply, but was able to found just trivial examples... so I have an issue I can't find a way to fix. So, i.e., I understand that with this: $domain5 = Capsule::table('tbldomains')->where('status', '=', 'Active')->select('id', 'domain')->first(); I can retrieve from db the first active domain, and with $domain5-> id I can retrieve its id , and so on... And with: $domain5 = Capsule::table('tbldomains')->where('status', '=', 'Active')->select('id', 'domain')->get(); I should retrieve all the active domains but... how to retrieve the data of every single domain? I tried (unsuccessfully) to var_export($domain5) and var_dump($domain5) to analyze the structure and understand how to retrieve single fields of every record, but it doesn't work... So, what are the right methods to do it?! 🤔 Edited November 3, 2022 by Walther 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted November 3, 2022 Share Posted November 3, 2022 Hi Walther, You are only selecting the id and domain for each row where the domain is active, if you want all data you can use $domain5 = Capsule::table('tbldomains')->where('status', 'Active')->get(); You can also use the Domain model to achieve this $domain5 = Domain::where('status', 'Active')->get(); Ensure to import at the top of the file use WHMCS\Domain\Domain; 1 Quote Link to comment Share on other sites More sharing options...
steven99 Posted November 3, 2022 Share Posted November 3, 2022 For docs on the Domain model, check: https://classdocs.whmcs.com/8.6/WHMCS/Domain/Domain.html . Change version to version in use for that specific one. Using capsule directly will not produce the model and just the direct database data for the domains table. You will get essentially the same info but in some cases the Model will have different variable names then the database column names. So using one over the other depends on a few factors. 1 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted November 3, 2022 Share Posted November 3, 2022 49 minutes ago, steven99 said: For docs on the Domain model, check: https://classdocs.whmcs.com/8.6/WHMCS/Domain/Domain.html . Change version to version in use for that specific one. Using capsule directly will not produce the model and just the direct database data for the domains table. You will get essentially the same info but in some cases the Model will have different variable names then the database column names. So using one over the other depends on a few factors. Yes, I offered the Model as an alternative just in case he wants to further expand it and grab client details, order details, etc... without the hassle of using joins. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.