Jump to content


Member Since 06 May 2003
Offline Last Active Yesterday, 10:17 PM

Posts I've Made

In Topic: PHP hierarchical MVC design from scratch?

22 June 2016 - 11:45 PM

I agree with Jacques. I was going to suggest you take a look at Symfony's routing component as an example: http://symfony.com/d...rk/routing.html

In Topic: Laravel ORM (Eloquent) and the real world

08 June 2016 - 04:06 PM

My experience mirrors Kicken. I had worked on a large symfony1 app, as well as a big ZF1 project before symfony2 and ZF2 became things.
I used various database libraries and ORM's on those projects, Propel for the Symfony1 project as I recall.

At that time Doctrine1 existed, and then the symfony2 project came out with a much higher binding to Doctrine2, in borrowing some of the things that the Doctrine2 people had created for annotation and event handling.

Whenever you are dealing with an ORM it takes a bit of time to change your thinking, because ORM's are concerned with "objects" and not tables. Often that is advantageous (see Kicken's example Doctrine2 code) and once you start to use all that baked in goodness you really come to appreciate what it can do for you.

With that said, it is not always the most efficient code, nor memory friendly, and people that just want to write raw sql have a hard time dealing with it. To have it work properly you have to design your tables and relations the right way, and it helps save time if you use their conventions, or you have to do extra configuration.

Instead of thinking about the relationships between tables, you have to think about the relationships between objects, and the ORM will often have default behavior that tries to do all sorts of things that make it simple for you to deal with data, but sometimes you realize that it's doing lots of queries you don't want it to do.

Ok, so much of that has to do with doctrine2 and symfony2, which I used on a project to build a pretty complicated (not to mention supposedly scalable) social network application that included social graphs and lots of the the stuff you expect in those types of apps. We also threw in MongoDB and built a hybrid app where some of the data was in a relational store, and some data was in mongo.
Doctrine2 allows you to use the same basic model and repository classes which was very helpful in stitching everything together.

I also have worked on several Laravel projects, and Eloquent has similar capabilities, but is far less ambitious.

To understand Eloquent, the main thing you need to know is that the goal of Eloquent is to implement ActiveRecord. ActiveRecord is a design pattern proposed by Martin Fowler where there's more or less a one-to-one relationship between a class and a table, and each object represents a single row in a table. You then have methods like $obj->save(); My take on Eloquent is that it does the bare minimum to be an Active Record implementation, and there's nothing wrong with that approach. Like most ORM's it has a querybuilder component that often strikes people who are used to hand crafting their SQL as being an annoyance and not worth the trouble.

However, once your application begins to get more complex and you have components that implement pagination and integrate with caching libraries, and in general becomes more sophisticated, you start to see the value of having an ORM that often supports and integrates with the component libraries.

In Topic: call to undefine function

03 June 2016 - 06:29 PM

You should be getting a parsing error from the look of it, because your functions are not ended properly.

function_name() {
In both cases your HEREDOC closing is outside of the end of the function.

Furthermore HEREDOCS work like so:

$var = <<<HEREDOC
echo $var;

In Topic: serialize() form values

30 May 2016 - 07:36 PM

Well I'm not sure what you are expecting. You have a destino input element in the form but it is given no value.

   <div class="form-group">
       <label class="col-xs-12">Destino</label>
       <input class="form-control" name="destino" id="destino">

If whatever code actually set a value for that element, then I suspect that things would work. If there is some jquery that is being used to set that dynamically, you haven't provided it.

In Topic: PHP MySQL Update Serialised Data

28 May 2016 - 06:54 PM

Yes, well, if that's the case, then you're going to have to read each row in, in a loop, unserialize it into an object, change those values in the php object, serialize and store the data back with an UPDATE statement.