PHP Classes

Doctrine PHP ORM Example: Examples of storing objects using Doctrine

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 71 All time: 10,267 This week: 455Up
Version License PHP version Categories
orm 1.0.0BSD License5PHP 5, Databases, Design Patterns
Description 

Author

This package provides examples of storing objects using Doctrine.

It provides several entity classes of objects mapped to database table records using Doctrine entity manager.

The package also provides a SQL script to install the database tables to store the entity class objects and an example script to show how to use the entity classes to perform several types of operations with entity objects.

Innovation Award
PHP Programming Innovation award nominee
February 2022
Number 10
Doctrine is a popular PHP project that helps developers to implement object-relational mapping actions in a PHP project.

These actions include storing and retrieving database table records using values set in PHP entity class objects.

This package shows how to use PHP Doctrine in practice in an example PHP application.

Manuel Lemos
Picture of Vitalij Mik
  Performance   Level  
Name: Vitalij Mik <contact>
Classes: 7 packages by
Country: Germany Germany
Age: 37
All time rank: 3482194 in Germany Germany
Week rank: 288 Up12 in Germany Germany Up
Innovation award
Innovation award
Nominee: 5x

Example

<?php

use BlackScorp\ORM\Entity\User;

$container = require_once __DIR__.'/depdency.php';

/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager = $container[\Doctrine\ORM\EntityManagerInterface::class]();

/** @var \BlackScorp\ORM\Entity\User $user */
$user = $entityManager->find(User::class,1);
/** @var \BlackScorp\ORM\Entity\CartProducts $cartProduct */
foreach ($user->getCartProducts()->getIterator() as $cartProduct){
   
var_dump($cartProduct->getQuantity());
   
var_dump($cartProduct->getProduct()->getTitle());
   
var_dump($cartProduct->getProduct()->getPrice());

   
$cartProduct->setQuantity($cartProduct->getQuantity()+1);
   
$product = $cartProduct->getProduct();
   
$product->setPrice($_POST);
   
$entityManager->persist($product);
}

$entityManager->flush();


Details

orm


  Files folder image Files (9)  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file depdency.php Conf. Configuration script
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file install.sql Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (9)  /  src  
File Role Description
Files folder imageEntity (4 files)

  Files folder image Files (9)  /  src  /  Entity  
File Role Description
  Plain text file CartProducts.php Class Class source
  Plain text file IdTrait.php Class Class source
  Plain text file Product.php Class Class source
  Plain text file User.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:71
This week:0
All time:10,267
This week:455Up