Welcome Guest, Not a member yet? Register   Sign In
Structure and Concept
#1

[eluser]RockKeeper[/eluser]
Hi!
At first i have to say that i'm a) new to codeiniter and b)german so my english isn't very well...

Well, when i was finding codeigniter, i was very happy about its concept and usability...
I planned a test-project (contact-database) to discover the possibilities of this framework and have now a question about it:

I want to use several classes for my data-objects like contact-person, country etc. to handle them and its actions... But the first question i have: where should i store the class-files of my own data-objects in the codeigniter folders ? At first i thought to store them in controllers oder models, but they aren't any of them... they are only business-objects with informations about the data-structure and without direct connection to the pages or page-logic ... hope anybody understand my try to explain my problem Smile

... the concept about the controlers, models and views i understand... i think Smile ...but i do not understand where to put these kind of files i explained above..

however, thanks in advance...
#2

[eluser]wiredesignz[/eluser]
Database access and business logic to operate on the data should be in your Models, Libraries can also contain business logic for the object they represent but they should only access the database through your Model.

Welcome to CI Forums.
#3

[eluser]RockKeeper[/eluser]
Oh, thanks for the fast answer!!

Ok, that makes sence .. .i have to change my way of coding a little bit ... Till now, i seperated the classes from the database-logic ... e.g.:

Code:
class ContactPerson{
  
   var $SomeProperties...

   function ContactPerson(){
     //Do something...
   }

   function save(){
      myContactSaveFuntion($this);
   }

   function delete(){
     myContactDeleteFunction($this->Id);
   }

   // and so on with some specific functions...
}


But the databse actions i put into the persistence-files like ContactPerson.pers.php:

Code:
function myContactSaveFuntion($contactperson){
   // do the database stuff like save etc...
}


So, if i understand you, i'll have to put the database actions (sql-queries) into the business-object an d put them into the models folder... right ?
#4

[eluser]wiredesignz[/eluser]
Using ORM style coding you can use a Model to represent your ContactPerson class with all logic and database access built in.

I prefer to use a ContactPerson class Library with his business logic and use a Contacts Model to represent my `contacts` table with data access through my Model.

You choose.
#5

[eluser]RockKeeper[/eluser]
Thank you very much! Now i have enough informations to choose how i proceed ... wonderful Smile




Theme © iAndrew 2016 - Forum software by © MyBB