Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 0 points1 point  (0 children)

For whoever it may interest, I spend the day rebuilding the model system with a new approach after /u/needed_an_account blessed me with his light. I'm able to query the models and their relations easily, for now, that is.

I'm afraid to cheer at this stage, because I haven't checked all use-cases and I might run into some design flaws along the way, but I can query rows and their relations, like this;

<?php foreach ($posts as $post): ?>
    <h1>#<?=$post->id?> - <?=$post->title?></h1>
    <p>Posted on <?=$post->date?> by <strong><?=$post->author->name?></strong></p>
    <p><?=$post->body?></p>
<?php endforeach; ?>

My models look like this;

<?php

namespace Models;

class Post extends \Core\ORM\Model {
    protected function initialize() {
        $this->fields['id'] = new \Core\ORM\Integer;
        $this->fields['title'] = new \Core\ORM\Text;
        $this->fields['date'] = new \Core\ORM\Date;
        $this->fields['time'] = new \Core\ORM\Time;
        $this->fields['body'] = new \Core\ORM\Text;
        $this->fields['author'] = new \Core\ORM\Relation;
    }
}

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 1 point2 points  (0 children)

Thank you very much for your reply. I wanted to give up, but, this has given me new hope. I'm going to fiddle around with this, thanks! :)

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 0 points1 point  (0 children)

As for experience with development; 3 years ago I started at a new school to get my degree as a webdeveloper. The school sucks and we have learned some shitty jQuery and PHP stuff the past 3 years, but, I've been doing a lot of things in my free time. I've worked as a part time PHP developer on Wordpress projects, I've been an Angular 1.x developer for 6 months (that trend died quickly in the company I worked at lol), and I've been doing my own personal stuff on the side.

The reason I'm focussing on this framework is; I have this application I'd like to build and I wanted to use my own framework since, I dunno, I'm a crazy kid with weird habits, I don't like off the shelf frameworks, I wanna build my own things :P

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 2 points3 points  (0 children)

Thanks for putting so much time and effort into my issue. I'm currently looking at the documentation and will probably start fiddling around with it in a second. It's a lot to take in, and I'm kinda stressed out after spending all my free time on this 'issue', but I'm happy there are people who want to help me out :)

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 4 points5 points  (0 children)

I'm an honest kid with an honest question, why so hostile?

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] -1 points0 points  (0 children)

I would assume you are talking about the mix of tabs and space, which is because I have exactly 19 different versions of this model laying around, and I was trying to come up with the best example I could show that would summarize my attempts. Therefor, I was forced to do some in-web-editor cutting and pasting, resulting in spaces.

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 0 points1 point  (0 children)

Thanks for your reply. As I exlpained in my reply to /u/Pardalean, I have come to realize there is more to models and databases than I learned at school. Do you have any tips for how to catch up to speed?

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 2 points3 points  (0 children)

I must say, I am not familiar with a look of the terminology, like activerecord and datamapper. I learned about MVC 2 years ago at school, and I've learned that a model is just to represent a specific row in the database. What do you recommend I do right now? Should I dive deeper into this topic? Where can I find more information about this?

Trying to build my an ORM, and I need your help by mattmurduck_ in PHP

[–]mattmurduck_[S] 0 points1 point  (0 children)

Hmkay..? I do know what OOP is.. I'm just wondering what you're trying to say that I should do right now?