Could not get table class for class: Eng1
This question has been answered by multiple community members. See the first response.
$xpdo = new xPDO('mysql:host=localhost;dbname=leagues',$username,$password); //$xpdo->setDebug(true); /* set default properties */ $leagueName = !empty($leagueName) ? $leagueName : ''; $rowTpl = !empty($rowTpl) ? $rowTpl : ''; $output = ''; if (!$xpdo->addPackage('league_pack','C:/xampp/htdocs/repo/revolution/core/components/league_pack/model/','')) { return 'Can not load package'; } $c = $xpdo->newQuery($leagueName); $c->select('id,home'); $c->sortby('home','ASC'); $rows = $xpdo->getCollection($leagueName,$c); foreach ($rows as $row) { $line = $row->toArray('',false,true); $data[] = $line[home]; } $rows = array_values(array_unique($data)); foreach ($rows as $row) { $ph[] = $modx->setPlaceholder('teamName', $row); $result .= $modx->getChunk($rowTpl,$ph); } etc...
$xpdo = new xPDO('mysql:host=localhost;dbname=leagues',$username,$password); //$xpdo->setDebug(true); /* set default properties */ $league = !empty($league) ? $league : ''; $htscore = $htscore != 'na' ? explode('-', $htscore) : 'na'; $season = !empty($season) ? $season : ''; $goaltime = $goaltime != 'na' ? explode('-', $goaltime) : 'na'; $gtFilterVar01 = $goaltime != 'na' ? $goaltime[1] : false; $gtFilterVar02 = $goaltime != 'na' ? $goaltime[2] : false; $eqlGoaltime = $eqlGoaltime != 'na' ? explode('-', $eqlGoaltime) : 'na'; if (!$xpdo->addPackage('league_pack','C:/xampp/htdocs/repo/revolution/core/components/league_pack/model/','')) { return 'Can not load package'; } //Last updated $d = $xpdo->newQuery($league); $d->sortby('id','DESC'); $d->limit(1); $d = $xpdo->getObject($league,$d); $updated = !empty($d) ? $d->get('date') : ''; $c = $xpdo->newQuery($league); if ($htscore != 'na') { $c->where(array( 'hthg' => $htscore[0], 'htag' => $htscore[1], )); } if ($season != 'na') { $c->where(array( 'season' => $season, )); } $rows = $xpdo->getCollection($league,$c); foreach ($rows as $row) { $array = $row->toArray(); etc...
Have you considered sharing a single $xpdo connection to this custom database? You can have one snippet—which executes first—create the database connection and set the package, then set the xPDO instance as placeholder. Then these two snippets can use that placeholder to get the single xPDO instance to work with.
// Get $modx // Get xpdo $xpdo = $modx->getPlaceholder("my.xpdo"); if ($xpdo == "") { $xpdo = new xPDO('mysql:host=localhost;dbname=leagues',$username,$password); $modx->setPlaceholder("my.xpdo", $xpdo); } // Use xpdo