We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44870
    • 35 Posts
    I'm trying to get Pagehits 1.0-beta2 working on modx revolution 2.2.10
    Snippet displays results in manager only if I manually add my prefix before site_content table in code below (pagehits.class.php). Otherwise I get error

    public function prepareQueryBeforeCount(xPDOQuery $c) {
        	$c->select(array('id', '(SELECT pagetitle FROM ' . $modx->db->config['table_prefix']  . 'my-prefix_site_content WHERE id = resource_id) AS pagetitle', 'COUNT(resource_id) AS hits', 'resource_id')) ;
        	$c->groupBy('resource_id');
        	$c->prepare() ;
        	return $c;
    	}

    Error log:
    Array
    (
        [0] => 42000
        [1] => 1146
        [2] => Table 'p465428228.site_content' doesn't exist
    )


    Can anybody help to change code to get table_prefix automaticly?