Export to GitHub

db2php - issue #19

Please help !!!!!!!!!!!!!!!!!!!!!!!!!


Posted on Apr 19, 2013 by Happy Rhino

i downloaded the following netbeans plugin : db2phpnb-1.107.nbm from ¨Project home page i opened netbeans and installed the plugin successfully i created a new php projet in netbeans and i started to create a new blank php page and in the dialog , i clicked on PHP Entity Class from Database i selected the database connection from the menu and after i selected all the available tables shown in the listbox then i clicked next then finish , the Model class are created in the root folder of my php application ( webapp ) : webapp/models

and then i started coding , i tried to copy paste the example provided :

<?php include_once 'SituMembersModel.class.php'; $db=new PDO('mysql:dbname=situ;host=localhost', 'user', 'password');

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

i made all changes for my database :

include_once 'SituMembersModel.class.php'; became include_once 'models/MessagesModel.class.php'; SituMembersModel became MessagesModel.class.php SiteMembersModel() became MessagesModel() SituMembersModel::findByExample became Messages::findByExample and so on ...

i tried to execute but it fails !!!!

it showns error like these :

Error # 1 :

Fatal error: Class 'Db2PhpEntityBase' not found in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php on line 9

This error was fixed by generating the php helpers available in this version of netbeans

the i have had now a new folder in my webapp called helpers : webapp\helpers

and this time i tried to include the missed class in the root file ( index.php ) where i started coding and now the error disappear and a new error is shown instead

Error # 2 :

Fatal error: Interface 'Db2PhpEntity' not found in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\helpers\Db2PhpEntityBase.class.php on line 36

this time it needs a new class interface to work properly , i do the same by including this class first and then the previous one , and now it should work , but a new error is shown

Error # 3 :

Fatal error: Interface 'Db2PhpEntityModificationTracking' not found in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php on line 9

the same as the previous ones , i included this one after the two others

so finaly we will get something like this :

include('helpers/Db2PhpEntity.class.php'); include('helpers/Db2PhpEntityBase.class.php'); include('helpers/Db2PhpEntityModificationTracking.class.php'); include('models/Messages.class.php');

and this time it should work , but unfortunately , not yet , another errors will be displayed like the next one :

Error #4 :

Fatal error: Class 'DFCAggregate' not found in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php on line 493

and after fixing it , the last one is :

Error #5 :

Fatal error: Interface 'DFCInterface' not found in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\helpers\DFCAggregate.class.php on line 35

and then this one :

Error #6 :

Fatal error: Class 'DSC' not found in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php on line 560

and then this one :

Error #7

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 \'"messages"\' at line 1', )' in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php:514 Stack trace: #0 C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php(501): Messages::fromStatement(Object(PDOStatement)) #1 C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php(474): Messages::findByFilter(Object(PDO), Array, true, NULL) #2 C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\index.php(24): Messages::findByExample(Object(PDO), Object(Messages)) #3 {main} thrown in C:\Program Files\Apache Software Foundation\Apache HTTP Server\htdocs\webMessaging\models\Messages.class.php on line 514

Now my question is that after fixing all this errors by including the required dependencies to get the result of my code , i found that the generated Models classes throw exceptions which shows that the code needs to be cleaned and fixed ...

I found others errors in the called methods in your class ...

Can you help me a clean version of db2php because i need it for my project ... ??????????

Comment #1

Posted on Apr 20, 2013 by Grumpy Horse

Did you consider including the missing classes?

Comment #2

Posted on Apr 24, 2013 by Swift Camel

Hello,

I have the same problems from yesterday. I started a new project with db2php classes but I get alsways the errors : Fatal Error: Class ....... not found in ... .

I have already cleaned and regenerate all classes (helpers and models from db) but is always the same.

Can anyone help me to find the problem and fix it?

Thank u in advance!

Giovanni

Comment #3

Posted on May 2, 2013 by Happy Rhino

it sounds not good for this library to work properly , because even i succeeded to fix te above errors , each time i start a new project , the same "nightmare" is started again and again , which means that the same errors should fixed again...

Don't you think that you library need a revision and update to fix these errors only once a time ? don't you think to fix the problems in Helpers Class because it fails in inclusion and when using CRUD Methods ( Insert , Update , Delete , Select or Find ) ????

Comment #4

Posted on May 3, 2013 by Happy Rhino

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

Status: Invalid

Labels:
Type-Defect Priority-Medium