O'Reilly logo

Learning Phalcon PHP by Calin Rada

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CRUD operations using ORM

By using the ORM, there is virtually no need to write any SQL in your code. Everything is OOP, and it is using the models to perform operations. The first, and the most basic, operation is retrieving data. In the old days, you would do this:

$result = mysql_query("SELECT * FROM article");

The class that our models are extending is \Phalcon\Mvc\Model. This class has some very useful methods built in, such as find(), findFirst(), count(), sum(), maximum(), minimum(), average(), save(), create(), update(), and delete().

CRUD – reading data

We have already used the find() method in our article manager when calling Article::find(). By default, this method will return all the records from the article table, sorting them in a natural ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required