PHP Classes

MySQL Class Generator: Generate classes to access MySQL as objects

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (37)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStarStar 80%Total: 1,030 All time: 3,566 This week: 107Up
Version License PHP version Categories
mysqlreflection 1.0.11BSD License5PHP 5, Databases, Code Generation
Description 

Author

This package can perform automatic generation of PHP classes from MySQL tables.

It is able to access to a given MySQL database and retrieve schema tables and fields.

For each table it generates a class that provides methods for accessing, reading and writing its records by using object oriented programming logic.

Each generated PHP class provides Setter and Getter methods for all table fields, as well as methods for CRUD operations.

Recommendations

Map database records to objects
Store and retrieve objects without writing native SQL again

What is the best PHP crud class?
How to create CRUD with PHP

doing all crud operations
doing all crud operations with one class

What is the best PHP crud class?
Manage and display staff details from database

database crud for each table
Package to analyze each table and create pdo crud for each

mysql database
script for update mysql database

How to find package ?
I'd like find package for accessing MySQL database.

php class file for InnoDB having the transaction handling
Mysql Innodb connection handling in PHP

PHPeclipse - PHP - Code Templates
Generate DB class, manager and exception file like PHPeclipse

MySQL table editor
Need to be able to create an interface to edit the table data

Good and simple MySQL wrapper
What MySQL wrapper should I go with?

Best PHP mysql to mysqli or PDO solution
How to convert mysql code to use mysqli?

Access data base
Pre-written PHP MySQL functions class

Picture of Saro Carvello
  Performance   Level  
Name: Saro Carvello <contact>
Classes: 2 packages by
Country: Italy Italy
Age: 56
All time rank: 147261 in Italy Italy
Week rank: 81 Up4 in Italy Italy Up

Example

<?php
include_once("mysqlreflection.config.php");
define("DESTINATION_PATH",dirname(__FILE__) . "/beans/");
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <title>MySQL Database Bean Builder</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Bootstrap core CSS -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" media="screen">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
    <![endif]-->
    <style>
        .progress {
                background: rgba(204, 237, 220, 1);
                border: 5px solid rgba(56, 46, 166, 0.27);
                border-radius: 10px; height: 36px;
        }
    </style>
<script>
    var globalCount =0 ;
    var globalPercent = 0;
</script>
<body>
<div class="container">
    <h1>MySQL Database Beans generator</h1>
    <h3>This utility performs automatically a source code generation of PHP
        Classes from MySQL tables </h3>
    <h4>Current database :<?= DBNAME ?> (to change it edit mysqlreflection.config.php)</h4>
    <h4>Destination path :<?= DESTINATION_PATH ?></h4>

    <a class="btn btn-success" onclick="document.getElementById('results').value = ''" href="?build=1"><span class="glyphicon glyphicon-wrench"></span> Generate classes</a>
    <a href="../builders/index" class="btn btn-info"><span class="glyphicon glyphicon-home"></span> Home</a>
    <br /> <br />
    <div class="progress progress-striped">
        <div class="progress-bar" role="progressbar" aria-valuenow="0"
             aria-valuemin="0" aria-valuemax="100" style="width:0%">
        </div>
    </div>

    <div class="text-center">
        <textarea cols="140" rows="20" id="results" name "results"></textarea>
    </div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js"></script>

<script>
    function aggiornaProgressBar(done=false) {
        var step = 2;
        var progress = $('.progress-bar');
        var currentValue = parseInt(progress.attr("aria-valuenow"));
        globalCount = globalCount +1;
        globalPercent = globalPercent +1;
        if (currentValue==100) {
            currentValue = 50;
        }
        currentValue += 1;
        progress.attr("aria-valuenow",currentValue);
        var percValue = currentValue + '%';
        progress.css('width',percValue);

        var textarea = document.getElementById('results');
        textarea.scrollTop = textarea.scrollHeight;

        if (done) {
            progress.attr("aria-valuenow",100);
            progress.css('width',"100%");
            percValue = "Done. " + globalCount + " classes were generated";
        }
        progress.html(percValue);
    }

    function aggiornaTextArea(msg){
        var m = msg + '&#xA;';
        $('#results').append(m);

    }

    function setNumberOfTables(ntables){
        if (numberOfTables === 'undefined' || !numberOfTables)
            var numberOfTables=ntables;
    }
</script>

</body>

<?php
if (isset($_GET["build"])) {
   
/**
     * Demo application: generate classes from a mysql db schema
     */

    // CLI mode
    // error_reporting(E_ALL);
    // include_once("mysqlreflection/mysqlreflection.config.php");
    // header('Content-Type: text/html; charset=utf-8');

   
$msg = "Building classes for mysql schema:[" . DBNAME . "]";
   
// CLI mode
    // echo $msg;
   
echo "<script>$('#results').append('" . $msg . "');</script>";

   
// Destination path for the generated classes
   
$destinationPath = DESTINATION_PATH;
   
// $destinationPath = "source/";

    // Create reflection object and invoke classes generation from the specified schema into mysql_connection.inc.php
   
$reflection = new MVCMySqlSchemaReflection();

   
// Generates the classes into the given path. During the generation it outputs the results.
   
$reflection->generateClassesFromSchema($destinationPath);

   
// CLI Mode
    // echo "<hr>Done.";
    // echo "<script> window.scrollTo(0,document.body.scrollHeight);</script>";

   
echo "<script>$('#results').append('" . "Done." . "&#xA;" . "');</script>";
    echo
"<script>aggiornaProgressBar(true);</script>";
}
?>


Screenshots  
  • ClassModel.png
  • gui
  • how_it_works
Videos  
  • Convert MySQL into PHP Classes automatically
  Files folder image Files  
File Role Description
Files folder imagebeans (17 files)
Files folder imagedocs (6 files)
Files folder imagemysqlreflection (7 files)
Files folder imagesql (1 file)
Accessible without login Plain text file app_create_beans.php Example Example script
Accessible without login Plain text file app_run_bean.php Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file mysqlreflection.config.php Aux. Auxiliary script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  beans  
File Role Description
  Accessible without login Plain text file bean.config.php Aux. Auxiliary script
  Plain text file BeanAclActions.php Class Class source
  Plain text file BeanDepartments.php Class Class source
  Plain text file BeanDeptEmp.php Class Class source
  Plain text file BeanDeptManager.php Class Class source
  Plain text file BeanEmployees.php Class Class source
  Plain text file BeanMultiplePk.php Class Class source
  Plain text file BeanSalaries.php Class Class source
  Plain text file BeanSinglePkDate.php Class Class source
  Plain text file BeanSinglePkDateTime.php Class Class source
  Plain text file BeanSinglePkInt.php Class Class source
  Plain text file BeanSinglePkIntAuto.php Class Class source
  Plain text file BeanSinglePkString.php Class Class source
  Plain text file BeanTitles.php Class Class source
  Plain text file BeanUser.php Class Class source
  Plain text file Model.php Class Class source
  Plain text file MySqlRecord.php Class Class source

  Files folder image Files  /  docs  
File Role Description
  Accessible without login Image file gui.png Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login Image file MySQLReflection.png Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation
  Accessible without login Plain text file tutorial_text.txt Doc. Documentation
  Accessible without login Image file UMLClassModel.png Data Auxiliary data

  Files folder image Files  /  mysqlreflection  
File Role Description
  Plain text file MVCMySqlBeanBuilder.php Class Class source
  Plain text file MVCMySqlBeanClass.php.tpl Class Class source
  Plain text file MVCMySqlFieldToAttributeReflection.php Class Class source
  Plain text file MVCMySqlPKAnalyzer.php Class Class source
  Plain text file MVCMySqlSchemaReflection.php Class Class source
  Plain text file MVCMySqlSimpleTemplate.php Class Class source
  Plain text file MVCMySqlTableReflection.php Class Class source

  Files folder image Files  /  sql  
File Role Description
  Accessible without login Plain text file bean_db.sql Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 92%
Total:1,030
This week:0
All time:3,566
This week:107Up
User Ratings User Comments (1)
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:75%StarStarStarStar
Overall:80%StarStarStarStarStar
Rank:15
 
Very useful to autogenerate PHP classes from MySQL.
6 years ago (Rossella Aiello)
87%StarStarStarStarStar