PDO Connection Error: SQLSTATE[42000]: Syntax error or access violation: 1064 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 '' at line 1
Error Code: #0
Source File: /home/laser/public_html/libraries/OF/core/general/DBO.php
line 29Backtrace
File: /home/laser/public_html/controls/pages/produtos.php
line 65DBO::execSQL(select count(*) as total from produtos where ativo = 1 and id_subcategoria = );Show Source Code
<?php
Oraculum_Request::init_sess();
Oraculum_Request::unsetsess('termos');
Oraculum_Request::unsetsess('idCategoria');
$url = Oraculum_Request::getvar('produtos');
$db = new Oraculum_Models('site');
$db->LoadModelClass('produtos', 'AR', 'id_produto');
$db->LoadModelClass('categorias', 'AR', 'id_categoria');
$db->LoadModelClass('fabricantes', 'AR', 'id_fabricante');
$db->LoadModelClass('arquivos', 'AR', 'id_arquivo');
$db->LoadModelClass('sub_cat');
$fabricantes = new Fabricantes();
$categorias = new Categorias();
$produtos = new Produtos();
$arquivos = new Arquivos();
$catSubCat = new Sub_Cat();
$page = (int) Oraculum_Request::getvar('page');
$rpp = 6; // Resultados por pagina
$page = $page == 0 ? 1 : $page;
//$offset = $offset > $total ? 0 : $offset;
$offset = ($rpp * ($page - 1));
Oraculum_Plugins::Load('pager');
$pager = new Oraculum_Pager;
//echo $url;
$suCate = Oraculum_Request::getvar($url);
//echo $url2;
if (!empty($url)) {
if ($url == "representadas") {
$urlfab = Oraculum_Request::getvar($url);
$fab = $fabricantes->getByUrl($urlfab, '%s');
} else {
$cate = DBO::execSQL("select * from categorias where tipo = 0 and url = '$url'");
$cate = $categorias->fetch($cate);
// echo sizeof($cate);
if (sizeof($cate) != 0) {
foreach ($cate as $cat) {
$cate = $cat;
// echo "Test".$cat->id_categoria;
}
$subCate = DBO::execSQL("select * from categorias where tipo = 1 and url = '$suCate'");
$subCate = $categorias->fetch($subCate);
if (sizeof($subCate) != 0) {
if (sizeof($subCate) == 1) {
foreach ($subCate as $sub) {
$subCate = $sub;
}
}else{
$lstSub = $catSubCat->getAllByCat_Prin($cate->id_categoria);
}
}
}
// $categorias->getByUrl($url, '%s');
}
} else {
$cate = $categorias->getById_Categoria(1);
}
$total = 0;
//$total = $produtos->getLinesByField('id_categoria',$cate->id_categoria);
//echo $fab->nome;
if (isset($fab)) {
$count_prod = DBO::ExecSQL("select count(*) as total from produtos where ativo = 1 and id_fabricante = $fab->id_fabricante ");
} else {
$count_prod = DBO::ExecSQL("select count(*) as total from produtos where ativo = 1 and id_subcategoria = $subCate->id_categoria");
Oraculum_Register::set('categoria', $subCate->categoria);
Oraculum_Register::set('idCategoria', $subCate->id_categoria);
}
$count_prod = $produtos->fetch($count_prod);
foreach ($count_prod as $ct) {
$total = $ct->total;
}
if (isset($fab)) {
$list_prod = DBO::ExecSQL("select * from produtos where ativo = 1 and id_fabricante = " . $fab->id_fabricante . " order by titulo limit $offset,$rpp");
$pager->setTotal($total)->setResults($rpp)->setPage($page)->setUrl(URL . 'produtos/representadas/' . $urlfab . '/page/');
} else {
$list_prod = DBO::ExecSQL("select * from produtos where ativo = 1 and id_subcategoria = " . $subCate->id_categoria . " order by titulo limit $offset,$rpp");
$pager->setTotal($total)->setResults($rpp)->setPage($page)->setUrl(URL . 'produtos/' . $url .'/'.$suCate. '/page/');
}
$list_prod = $produtos->fetch($list_prod);
$pager = $pager->ifneedpagination()->pager();
Oraculum_Register::set('pager', $pager);
Oraculum_Register::set('lista-produtos', $list_prod);
Oraculum_Register::set('tabela-arquivos', $arquivos);
Oraculum_Register::set('tabela-categorias', $categorias);
Oraculum_WebApp::LoadView()
->AddTemplate('geral')
->LoadPage('produtos');
File: /home/laser/public_html/libraries/OF/core/general/Controls.php
line 44include_once(
/home/laser/public_html/controls/pages/produtos.php);
Show Source Code
<?php
/**
* Tratamento de Controladores
*
*
* @filesource $HeadURL: https://oraculum-php.googlecode.com/svn/trunk/core/general/Controls.php $
* @category Framework
* @package oraculum
* @subpackage oraculum.core.controls
* @license http://www.opensource.org/licenses/lgpl-3.0.html (LGPLv3)
* @version $Revision: 90 $
* @modifiedby $LastChangedBy: Patrixsbs $
* @lastmodified $Date: 2012-05-24 13:46:17 -0300 (qui, 24 mai 2012) $
*
*/
class Oraculum_Controls
{
public function __construct() {
if (!defined('CONTROL_DIR')):
define('CONTROL_DIR', 'controls');
endif;
if (!defined('ERRORPAGE')):
define('ERRORPAGE', '404');
endif;
}
public function LoadPage($page=NULL, $url=NULL, $usetemplate=false)
{
if (is_null($page)) {
throw new Exception ('[Erro CGC31] Pagina nao informada');
} else {
$pagefile=CONTROL_DIR.'/pages/'.$page.'.php';
$urlfile=CONTROL_DIR.'/pages/'.$url.'.php';
$errorpage=CONTROL_DIR.'/pages/'.ERRORPAGE.'.php';
if ($page=='') {
$class=ucwords($url).'Controller';
} else {
$class=ucwords($page).'Controller';
}
if (file_exists($urlfile)) {
include_once($urlfile);
} elseif (file_exists($pagefile)) {
include_once($pagefile);
} elseif(file_exists($errorpage)) {
//header('HTTP/1.1 404 Not Found');
include_once($errorpage);
} else {
header('HTTP/1.1 404 Not Found');
throw new Exception('[Erro CGC50] Pagina nao encontrada ('.$pagefile.') ');
}
if (class_exists($class)) {
new $class;
}
}
return $this;
}
public static function LoadHelper($helper=NULL)
{
if (is_null($helper)) {
throw new Exception ('[Erro CGC62] Helper nao informado');
} else {
$helperfile=CONTROL_DIR.'/helpers/'.$helper.'.php';
if (file_exists($helperfile)) {
include_once($helperfile);
} else {
throw new Exception('[Erro CGC68] Helper nao encontrado ('.$helperfile.') ');
}
}
}
}
File: /home/laser/public_html/libraries/OF/core/general/FrontController.php
line 59Oraculum_Controls->LoadPage(1,representadas);Show Source Code
<?php
/**
* Tratamento de parametros HTTP
*
*
* @filesource $HeadURL: $
* @category Framework
* @package oraculum
* @subpackage oraculum.core.frontcontroller
* @license http://www.opensource.org/licenses/lgpl-3.0.html (LGPLv3)
* @version $Revision: $
* @modifiedby $LastChangedBy: Patrick $
* @lastmodified $Date: 2011-06-21 16:11:40 -0300 (Ter, 21 Jun 2011) $
*
*/
Oraculum::Load('Request');
class Oraculum_FrontController
{
private $_defaulturl=NULL;
private $_errorpage=NULL;
public function setBaseUrl($url) {
if (!defined('URL')) {
define('URL', $url);
$gets=Oraculum_Request::gets();
$base=(count(explode('/', URL))-2);
$base=strpos($gets[$base], '.php')?$base+2:$base;
define('BASE', $base);
}
return $this;
}
public function setDefaultPage($url) {
$this->_defaulturl=$url;
return $this;
}
public function setErrorPage($url) {
if (!defined('ERRORPAGE')) {
define('ERRORPAGE', $url);
}
return $this;
}
public function start() {
Oraculum::Load('Request');
$request=Oraculum_Request::request();
$url=str_ireplace(URL, '', $request);
$gets=Oraculum_Request::gets();
if (isset($gets[(BASE)+1])) {
$page=$gets[(BASE)+1];
} else {
$page=$this->_defaulturl;
//throw new Exception('[Erro CGFC36] Nao foi possivel determinar a pagina atraves da URL');
}
if ($url=='') {
$url=$this->_defaulturl;
}
Oraculum_App::LoadControl()->LoadPage($page, $url);
}
}
File: /home/laser/public_html/index.php
line 26Oraculum_FrontController->start();Show Source Code
<?php
ini_set('display_errors', true);
header('Content-Type: text/html; charset=iso-8859-1');
header('X-Powered-By: Oraculum PHP Framework');
date_default_timezone_set("America/Sao_Paulo");
//echo "teste";
include('./bootstrap.php');
Oraculum::LoadContainer('WebApp');
Oraculum::Load('Routes');
Oraculum::Load('Models');
Oraculum::Load('Exceptions');
Oraculum::Load('Text');
Oraculum::Load('Plugins');
Oraculum::Load('Request');
if($_SERVER['SERVER_NAME']=="localhost") {
$url='/Projetos/Laser_Representacoes/';
} else {
$url='/';
}
define("IMG", $url.'public/img/');
$app=new Oraculum_WebApp();
$app->FrontController()
->setBaseUrl($url)
->setDefaultPage('home')
->setErrorPage('404')
->start();