ajmeireles Posted August 28, 2018 Share Posted August 28, 2018 Hi, everyone, someone can help me? I need to get all parameters from tblhosting table from a specific client that have the domainstatus as ACTIVE. I'm trying with this code: Quote $pdo = Capsule::connection()->getPdo(); $pdo->beginTransaction(); $service = $pdo->prepare("SELECT userid, packageid, nextduedate, amount FROM tblhosting where domainstatus = Active"); $service->execute(); $row = $service->fetchColumn(); if($row->userid == 1) { //... working here } But isn't work if the user is really the userid 1. I know that is easy to do using foreach, for example: Quote $pdo = Capsule::connection()->getPdo(); $pdo->beginTransaction(); $service = $pdo->prepare("SELECT `userid` as `id`, `packageid` as `produto`, `nextduedate` as `vencimento`, `amount` as `value` FROM `tblhosting` WHERE `domainstatus` = 'Active'"); $service->execute(); $pdo->commit(); foreach($service AS $dados) { //... working here } For example, if I send a mail using localApi in foreach, the system will send more than 1 mail if the client have more than one actived service, due the foreach. Someone know some method to get all parameters from tblhosting and use it on single variable in a simple if condition? 0 Quote Link to comment Share on other sites More sharing options...
nasos75 Posted August 31, 2018 Share Posted August 31, 2018 $services = Capsule::table('tblhosting')->where('domainstatus','Active')->get(); foreach ($services as $service) { if ($service->userid == 1) { // code here... } } 0 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.