Selasa, 17 Februari 2015

Membuat Upload File dengan Doctrine 2 dan Zend Framework 2

Langkah pertama anda buatlah database terlebih dahulu dengan menggunakan doctrine, sebelumnya untuk membuat database pada doctrine telah dijelaskan. anda bisa lihat langsung pada tulisan saya sebelumnya. kemudian buatlah entity database anda, disini saya buat dengan nama user yang berada pada module/application/src/entity/ yang berisikan source seperti dibawah ini :

namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM;
 /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of User
 *
 * @author Candra
 */
/** @ORM\Entity */
class User {
    /**
     * @ORM\id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    protected $id;
    
    /** @ORM\Column(type="string") 
     */
    protected $fullName;
    
    /** @ORM\Column(type="string") 
     */
    protected $upload;
    
    /** @ORM\Column(type="string") 
     */
    
    //protected $alamat;
    
    /** @ORM\Column(type="string")
     */
    //protected $email;

    /** @ORM\Column(type="string",length=1) 
     */
    //protected $jk;
    
    // getters/setters
    
    function getId() {
        return $this->id;
    }

    function getFullName() {
        return $this->fullName;
    }

    function getAlamat() {
        return $this->alamat;
    }

    function getEmail() {
        return $this->email;
    }

    function getJk() {
        return $this->jk;
    }

    function setId($id) {
        $this->id = $id;
    }

    function setFullName($fullName) {
        $this->fullName = $fullName;
    }

    function setAlamat($alamat) {
        $this->alamat = $alamat;
    }

    function setEmail($email) {
        $this->email = $email;
    }

    function setJk($jk) {
        $this->jk = $jk;
    }
    function getUpload() {
        return $this->upload;
    }

    function setUpload($upload) {
        $this->upload = $upload;
    }

}