Welcome Guest, Not a member yet? Register   Sign In
creating objects
#1

[eluser]timaksu[/eluser]
hey guys. when i go to save a post to my database, in the controller i do this:

Code:
$post->title = "title";
$post->date=now();
$post->content = "blablablalblab";

$this->post_model->save($post);


from which point the model does the rest however, i want to create an actual post object rather than what im doing above...an object with a constructor etc.

Code:
$post = new Post();
$post.set_title('title');
$post.set_content('content');

etc.

now i dont need to know how to write up all this..what i want to know is where would i actually place the code for this class? i need this class accessible everywhere ofcourse..so where?
#2

[eluser]timaksu[/eluser]
bump..still have no idea where to place the code for custom object classes
#3

[eluser]überfuzz[/eluser]
Not really an answer to you question but anyway.

Are you using CI? If yes: Have you ever considered using active records?
#4

[eluser]wiredesignz[/eluser]
The code for your own classes can be placed in application/libraries or application/plugins directories.

Both types can be loaded as needed by your application but note that library classes are instantiated by CodeIgniter after loading and plugin classes are not.
#5

[eluser]kurucu[/eluser]
As well as the active record class, it would be worth you looking up DMZ (which I have started pronouncing Dee Em Zee in my head, despite being English). It seems like it might save you some time.




Theme © iAndrew 2016 - Forum software by © MyBB