slam4:php:phalcon:models

Ceci est une ancienne révision du document !


Modèles

Un modèle est une classe métier, représentant une partie des données d'une application. Dans la plupart des cas, un modèle est associé à une table de la base de données.
Phalcon\Mvc\Model est la classe de base des models d'une application. Cette classe met à disposition des fonctionnalités CRUD, offre des possibilités de recherche avancées, et permet de gérer les relations entre models, le tout sans avoir besoin d'utiliser SQL.

<?php

class Utilisateur extends \Phalcon\Mvc\Model
{

}

Pour des raisons de clarté, et de performances (avec PHP 5.4/5.5), il est préférable de déclarer dans la classe les membres correspondant aux colonnes de la table de la base de données associée.

<?php
class Utilisateur extends \Phalcon\Mvc\Model{

    /**
     *
     * @var string
     */
    protected $prenom;

    /**
     *
     * @var integer
     */
    protected $id;

    /**
     *
     * @var string
     */
    protected $dateInscription;

    /**
     *
     * @var integer
     */
    protected $age;

    /**
     *
     * @var string
     */
    protected $nom;

    /**
     *
     * @var integer
     */
    protected $adulte;

    /**
     *
     * @var integer
     */
    protected $idCategorie;

    /**
     * Method to set the value of field prenom
     *
     * @param string $prenom
     * @return $this
     */
    public function setPrenom($prenom)
    {
        $this->prenom = $prenom;

        return $this;
    }

    /**
     * Method to set the value of field id
     *
     * @param integer $id
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Method to set the value of field dateInscription
     *
     * @param string $dateInscription
     * @return $this
     */
    public function setDateinscription($dateInscription)
    {
        $this->dateInscription = $dateInscription;

        return $this;
    }

    /**
     * Method to set the value of field age
     *
     * @param integer $age
     * @return $this
     */
    public function setAge($age)
    {
        $this->age = $age;

        return $this;
    }

    /**
     * Method to set the value of field nom
     *
     * @param string $nom
     * @return $this
     */
    public function setNom($nom)
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * Method to set the value of field adulte
     *
     * @param integer $adulte
     * @return $this
     */
    public function setAdulte($adulte)
    {
        $this->adulte = $adulte;

        return $this;
    }

    /**
     * Method to set the value of field idCategorie
     *
     * @param integer $idCategorie
     * @return $this
     */
    public function setIdcategorie($idCategorie)
    {
        $this->idCategorie = $idCategorie;

        return $this;
    }

    /**
     * Returns the value of field prenom
     *
     * @return string
     */
    public function getPrenom()
    {
        return $this->prenom;
    }

    /**
     * Returns the value of field id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Returns the value of field dateInscription
     *
     * @return string
     */
    public function getDateinscription()
    {
        return $this->dateInscription;
    }

    /**
     * Returns the value of field age
     *
     * @return integer
     */
    public function getAge()
    {
        return $this->age;
    }

    /**
     * Returns the value of field nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Returns the value of field adulte
     *
     * @return integer
     */
    public function getAdulte()
    {
        return $this->adulte;
    }

    /**
     * Returns the value of field idCategorie
     *
     * @return integer
     */
    public function getIdcategorie()
    {
        return $this->idCategorie;
    }

}

  • slam4/php/phalcon/models.1421155513.txt.gz
  • Dernière modification : il y a 7 ans
  • (modification externe)