Fatal Error in Gdn_Database.Query();

PDO Statement failed to prepare

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') and concat(WGFaBuTime, cd.DateInserted) >= concat(d.WGFaBuTime,d.DateInserted)' at line 4

The error occurred on or near: /home/wwwroot/www.vantk.com/beta/library/database/class.database.php

384:                 if (!is_null($InputParameters) && count($InputParameters) > 0) {
385:                     $PDOStatement = $PDO->prepare($Sql);
386: 
387:                     if (!is_object($PDOStatement)) {
388:                         trigger_error(errorMessage('PDO Statement failed to prepare', $this->ClassName, 'Query', $this->getPDOErrorMessage($PDO->errorInfo())), E_USER_ERROR);
389:                     } elseif ($PDOStatement->execute($InputParameters) === false) {
390:                         trigger_error(errorMessage($this->getPDOErrorMessage($PDOStatement->errorInfo()), $this->ClassName, 'Query', $Sql), E_USER_ERROR);
391:                     }
392:                 } else {

Backtrace:

/home/wwwroot/www.vantk.com/beta/library/database/class.database.phpPHP::Gdn_ErrorHandler();
[/home/wwwroot/www.vantk.com/beta/library/database/class.database.php:388] PHP::trigger_error();
[/home/wwwroot/www.vantk.com/beta/library/database/class.sqldriver.php:1690] Gdn_Database->query();
[/home/wwwroot/www.vantk.com/beta/library/database/class.sqldriver.php:614] Gdn_SQLDriver->query();
[/home/wwwroot/www.vantk.com/beta/applications/vanilla/models/class.discussionmodel.php:427] Gdn_SQLDriver->get();
[/home/wwwroot/www.vantk.com/beta/plugins/Vantk/class.vantk.plugin.php:558] DiscussionModel->getWhere();
[/home/wwwroot/www.vantk.com/beta/plugins/Vantk/class.vantk.plugin.php:449] VantkPlugin->_DaDaTu_ShuJu();
[/home/wwwroot/www.vantk.com/beta/library/core/class.pluginmanager.php:894] VantkPlugin->DiscussionsController_AfterInitialize_Handler();
[/home/wwwroot/www.vantk.com/beta/library/core/class.pluginmanager.php:798] Gdn_PluginManager->callEventHandler();
[/home/wwwroot/www.vantk.com/beta/library/core/class.pluggable.php:133] Gdn_PluginManager->callEventHandlers();
[/home/wwwroot/www.vantk.com/beta/applications/vanilla/controllers/class.discussionscontroller.php:303] Gdn_Pluggable->fireEvent();
[/home/wwwroot/www.vantk.com/beta/library/core/class.dispatcher.php:294] DiscussionsController->initialize();
[/home/wwwroot/www.vantk.com/beta/index.php:58] Gdn_Dispatcher->dispatch();

Variables in local scope:

[Sql] 'select case  when d.WGMode = 2 then 
                (
                    CEIL (
                        (SELECT COUNT(*) FROM `GDN_Discussion` cd  inner Join GDN_TagDiscussion td on cd.DiscussionID = td.DiscussionID WHERE cd.`WGMode` = 2  and (WGShenHe = 3 and WGFaBuTime <> \'2026-04-01 21:05:06\' and WGFaBuTime < \'2026-04-01 21:05:06\') and Type=\'article\' and td.TagID in () and concat(WGFaBuTime, cd.DateInserted) >= concat(d.WGFaBuTime,d.DateInserted) )  
                        /3
                    )
                )*2+1 else 
                CEIL (
                        (
                            (SELECT COUNT(*) FROM `GDN_Discussion` cd  inner Join GDN_TagDiscussion td on cd.DiscussionID = td.DiscussionID WHERE cd.`WGMode` <> 2  and (WGShenHe = 3 and WGFaBuTime <> \'2026-04-01 21:05:06\' and WGFaBuTime < \'2026-04-01 21:05:06\') and Type=\'article\' and td.TagID in () and concat(WGFaBuTime, cd.DateInserted) >= concat(d.WGFaBuTime,d.DateInserted) )
                            
                        )   
                        /3
                    )*2 end as `WGGroupOrderFixed`, d2.*
from GDN_Discussion d
join GDN_TagDiscussion td on d.DiscussionID = td.DiscussionID
join GDN_Discussion d2 on d.DiscussionID = d2.DiscussionID
where d.WGPicCover is not null
 and d.WGPicCover <> :dWGPicCover
 and td.TagID in (null)
 and d.Type = :dType
 and d.WGShenHe = :dWGShenHe
 and d.WGFaBuTime <> :dWGFaBuTime
 and d.WGFaBuTime < :dWGFaBuTime0
order by d.DateInserted desc, WGGroupOrderFixed asc, d.WGFaBuTime desc, d.DateInserted desc
limit 1'
[InputParameters] array (
  ':dWGPicCover' => '',
  ':dType' => 'article',
  ':dWGShenHe' => 3,
  ':dWGFaBuTime' => '2026-04-01 21:05:06',
  ':dWGFaBuTime0' => '2026-04-01 21:05:06',
)
[Options] array (
  'Type' => 'select',
  'Slave' => NULL,
  'ReturnType' => 'DataSet',
)
[ReturnType] 'DataSet'
[tries] 2
[try] 0
[PDO] array (
)
[PDOStatement] false

Need Help?

If you are a user of this website, you can report this message to a website administrator.

If you are an administrator of this website, you can get help at the Vanilla Community Forums.

Additional information for support personnel:

Array ( [0] => flannian-sql [1] => select case when d.WGMode = 2 then ( CEIL ( (SELECT COUNT(*) FROM `GDN_Discussion` cd inner Join GDN_TagDiscussion td on cd.DiscussionID = td.DiscussionID WHERE cd.`WGMode` = 2 and (WGShenHe = 3 and WGFaBuTime <> '2026-04-01 21:05:06' and WGFaBuTime < '2026-04-01 21:05:06') and Type='article' and td.TagID in () and concat(WGFaBuTime, cd.DateInserted) >= concat(d.WGFaBuTime,d.DateInserted) ) /3 ) )*2+1 else CEIL ( ( (SELECT COUNT(*) FROM `GDN_Discussion` cd inner Join GDN_TagDiscussion td on cd.DiscussionID = td.DiscussionID WHERE cd.`WGMode` <> 2 and (WGShenHe = 3 and WGFaBuTime <> '2026-04-01 21:05:06' and WGFaBuTime < '2026-04-01 21:05:06') and Type='article' and td.TagID in () and concat(WGFaBuTime, cd.DateInserted) >= concat(d.WGFaBuTime,d.DateInserted) ) ) /3 )*2 end as `WGGroupOrderFixed`, d2.* from GDN_Discussion d join GDN_TagDiscussion td on d.DiscussionID = td.DiscussionID join GDN_Discussion d2 on d.DiscussionID = d2.DiscussionID where d.WGPicCover is not null and d.WGPicCover <> :dWGPicCover and td.TagID in (null) and d.Type = :dType and d.WGShenHe = :dWGShenHe and d.WGFaBuTime <> :dWGFaBuTime and d.WGFaBuTime < :dWGFaBuTime0 order by d.DateInserted desc, WGGroupOrderFixed asc, d.WGFaBuTime desc, d.DateInserted desc limit 1 [2] => 42000 [3] => 1064 [4] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') and concat(WGFaBuTime, cd.DateInserted) >= concat(d.WGFaBuTime,d.DateInserted)' at line 4 [5] => no PDOStatement )