c4tom / db2php

Automatically exported from code.google.com/p/db2php
GNU General Public License v3.0
0 stars 0 forks source link

unknown exception ... what does it mean ? #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
i have reveiewed the issues found to fix some errors of db2php but i finally 
got this exception : 

Fatal error: Uncaught exception 'Exception' with message '00000:array ( 0 => 
'00000', 1 => 1064, 2 => '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 \'"categories"\' at line 1', )' in C:\Program Files\Apache Software 
Foundation\Apache HTTP 
Server\htdocs\db2php\models\CategoriesModel.class.php:448 Stack trace: #0 
C:\Program Files\Apache Software Foundation\Apache HTTP 
Server\htdocs\db2php\models\CategoriesModel.class.php(435): 
CategoriesModel::fromStatement(Object(PDOStatement)) #1 C:\Program Files\Apache 
Software Foundation\Apache HTTP 
Server\htdocs\db2php\models\CategoriesModel.class.php(408): 
CategoriesModel::findByFilter(Object(PDO), Array, true, NULL) #2 C:\Program 
Files\Apache Software Foundation\Apache HTTP 
Server\htdocs\db2php\index.php(27): CategoriesModel::findByExample(Object(PDO), 
Object(CategoriesModel)) #3 {main} thrown in C:\Program Files\Apache Software 
Foundation\Apache HTTP Server\htdocs\db2php\models\CategoriesModel.class.php on 
line 448

to run the following snippet : 

<?php

require_once 'helpers/Db2PhpEntity.class.php';
require_once 'helpers/Db2PhpEntityBase.class.php';
require_once 'helpers/Db2PhpEntityModificationTracking.class.php';
require_once 'helpers/DFCAggregate.class.php';
require_once 'helpers/DSC.class.php';

require_once 'helpers/DFC.class.php';
require_once 'helpers/DSC.class.php';

require_once 'models/CategoriesModel.class.php';

$db=new PDO('mysql:dbname=pfe;host=localhost', 'root', 'mrad');

// query all categories with dexterity=12 and reasoning=4 (query by example 
currently only available for PDO!)
$categories=new CategoriesModel();
//$example->setDexterity(12)->setReasoning(4);
foreach (CategoriesModel::findByExample($db, $categories) as $catergory) {
        echo $catergory->getId() . ':' . $catergory->getLabel() . "\n";
}

?>

can you help me fix it ? i could not be able to show the categories available 
in database on page ... 

Original issue reported on code.google.com by mrad1...@gmail.com on 2 May 2013 at 12:11

GoogleCodeExporter commented 9 years ago
i have made a new php script to resolve this kind of exception , this script 
should be included or required even once a time for every database request / 
response to perform , here is the code / example :

/* Helpers and Entities to Include */

include('common.inc.php');

/* Entities to Include */

include_once 'classes/Employees.class.php';

/* Connection */

$db=new PDO('mysql:dbname=pfe;host=localhost', 'root', 'mrad');

// query all members (query by example currently only available for PDO!)
$example= new Employees();

foreach (Employees::findByExample($db, $example) as $e) {
        echo $e->getLastName() . ':' . $e->getFirstName() . "\n";
}

where the common.inc.php is looking like that : 

/*
 * Common Inclusion Script 
 */

include 'helpers/DFCInterface.class.php';
include 'helpers/DFC.class.php';
include 'helpers/DFCAggregate.class.php';
include 'helpers/DSC.class.php';
include 'helpers/SimpleDatabaseInterface.class.php';

include 'helpers/Db2PhpEntity.class.php';
include 'helpers/Db2PhpEntityBase.class.php';
include 'helpers/Db2PhpEntityModificationTracking.class.php';

the script should be saved in the site root directory and helpers directory is 
the directory containing the helpers class files needed for db2php library to 
work properly and classes directory is the directory of generated entities / 
models from mysql database tables ...

Hope it helps 

Original comment by mrad1...@gmail.com on 3 May 2013 at 11:07