Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 3 files changed
  • 0 comments
  • 2 contributors
May 11, 2012
nico Enabled mysql server port congiguration as per jasonmoo/DumbledORM#1
…requested by jiminoc
26182f4
nico Added a PHP-CLI script to generate the models via the command line. Run
Generate DumbledORM models.

  Usage:
  ./generate.php <option>

  <option>
      -h, -?, --help, -help            Print this help message
      -p, --prefix <prefix>            Prefix generated classes
      -d, --dir <directory>            Output directory for the model instead of the default ./model  to see usage instructions.
76c7d8f
Jason Mooberry Merge pull request #2 from nickl-/master
"in any case": Effortless contributions
de6d46f

Showing 3 changed files with 30 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 0  config.php
  2. +1 1  dumbledorm.php
  3. +28 0 generate.php
1  config.php
... ... @@ -1,6 +1,7 @@
1 1 <?php
2 2 class DbConfig {
3 3 const HOST = 'localhost';
  4 + const PORT = 3306;
4 5 const DBNAME = 'test_database';
5 6 const USER = 'root';
6 7 const PASSWORD = 'password';
2  dumbledorm.php
@@ -141,7 +141,7 @@ public static function generateBase($prefix=null,$dir='model') {
141 141 */
142 142 public static function pdo() {
143 143 if (!self::$_pdo) {
144   - self::$_pdo = new PDO('mysql:host='.DbConfig::HOST.';dbname='.DbConfig::DBNAME, DbConfig::USER, DbConfig::PASSWORD);
  144 + self::$_pdo = new PDO('mysql:host='.DbConfig::HOST.';port='.DbConfig::PORT.';dbname='.DbConfig::DBNAME, DbConfig::USER, DbConfig::PASSWORD);
145 145 self::$_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
146 146 }
147 147 return self::$_pdo;
28 generate.php
... ... @@ -0,0 +1,28 @@
  1 +#!/usr/bin/php
  2 +<?php
  3 +if (in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
  4 +?>
  5 +
  6 +Generate DumbledORM models.
  7 +
  8 + Usage:
  9 + <?php echo $argv[0]; ?> <option>
  10 +
  11 + <option>
  12 + -h, -?, --help, -help Print this help message
  13 + -p, --prefix <prefix> Prefix generated classes
  14 + -d, --dir <directory> Output directory for the model instead of the default ./model
  15 +
  16 +<?php
  17 +} else {
  18 +$params = array(
  19 + 'p:' => 'prefix:',
  20 + 'd:' => 'dir:',
  21 +);
  22 +$opt = getopt(implode('', array_keys($params)), $params);
  23 +
  24 +require('config.php');
  25 +require('dumbledorm.php');
  26 +Builder::generateBase($opt['p'], ($opt['d'] ? $opt['d'] : 'model'));
  27 +}
  28 +?>

No commit comments for this range

Something went wrong with that request. Please try again.