TemKa_SD Posted October 22, 2018 Share Posted October 22, 2018 Здравствуйте, вот код: foreach(\IPS\Db::i('stats')->select('hero, newcolour', 'stats_dotaplayers', ['gameid=?', $row['gameid']]) as $dotaPlayer) { $hero = mb_strtoupper($dotaPlayer['hero']); $players[intval($dotaPlayer['newcolour'])] = $this->getHero($hero) ? $this->getHero($hero) : 'BLANKX'; } Здесь колонка hero может быть пустой, как указать для нее заглушку? Link to comment Share on other sites More sharing options...
newbie Posted October 23, 2018 Share Posted October 23, 2018 Так сделайте в методе getHero проверку на пустоИ тогда$players[intval($dotaPlayer['newcolour'])] = $this->getHero($hero); Либо foreach(\IPS\Db::i('stats')->select('hero, newcolour', 'stats_dotaplayers', ['gameid=?', $row['gameid']]) as $dotaPlayer) { $players[intval($dotaPlayer['newcolour'])] = $dotaPlayer['hero'] ? $this->getHero(mb_strtoupper($dotaPlayer['hero'])) : 'BLANKX'; } Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 23, 2018 Author Share Posted October 23, 2018 Так сделайте в методе getHero проверку на пусто Я пробовал в шаблоне, но там не работает, так как идут какие-то символы: http://prntscr.com/l9cpv9 нужно именно поле проверять. Link to comment Share on other sites More sharing options...
newbie Posted October 24, 2018 Share Posted October 24, 2018 Я пробовал в шаблоне,Не шаблон. public function getHero($hero) { if (!$hero) { return 'BLANKX'; } // Другой код } Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 24, 2018 Author Share Posted October 24, 2018 Всё же правильно: http://prntscr.com/l9s3rf Link to comment Share on other sites More sharing options...
newbie Posted October 24, 2018 Share Posted October 24, 2018 Так в чем проблема? Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 24, 2018 Author Share Posted October 24, 2018 http://prntscr.com/l9ses8 Link to comment Share on other sites More sharing options...
newbie Posted October 24, 2018 Share Posted October 24, 2018 Кодировку проверьтеUTF-8 без BOM Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 24, 2018 Author Share Posted October 24, 2018 http://prntscr.com/l9tq5x так пересохранил, всё тоже самое. Link to comment Share on other sites More sharing options...
newbie Posted October 24, 2018 Share Posted October 24, 2018 Без БОМ надо.Не знаю, что у Вас за редактор, и где искать настройки.Прикрепите php-файл Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 24, 2018 Author Share Posted October 24, 2018 Sublime Text у меня )recentGames.php Link to comment Share on other sites More sharing options...
newbie Posted October 24, 2018 Share Posted October 24, 2018 Ну, у Вас значение переменной $hero может быть чем угодно.Вы в базе смотрели значения? Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 24, 2018 Author Share Posted October 24, 2018 http://prntscr.com/l9uf6ohttp://prntscr.com/l9ufu1 Link to comment Share on other sites More sharing options...
TemKa_SD Posted October 25, 2018 Author Share Posted October 25, 2018 (edited) ку ку А понял, скрины не грузит. Я так и не решил этот вопрос, гляньте плиз чуть позже скрины. Там я показал, что ячейки пустые. Edited October 25, 2018 by TemKa_SD Link to comment Share on other sites More sharing options...
newbie Posted October 25, 2018 Share Posted October 25, 2018 Там я показал, что ячейки пустые. Там могут быть невидимые символыИзмените значение на 0 и посмотрите Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now