Skip to content

Commit

Permalink
Moved classes to subfolder.
Browse files Browse the repository at this point in the history
Added First Steps section in README.
  • Loading branch information
mynetx committed Mar 10, 2011
1 parent 8abc31d commit 2353204
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
49 changes: 49 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,52 @@ System requirements

To use this database wrapper, make sure the web server is running
at least PHP 5.2, or any higher version.


First steps
-----------

// load monty
require 'monty/loader.php';

// get the MySQL connector
$objConnector = Monty::getConnector();

// connect to a database
$objConnector->open('youruser', 'fancypass', 'holydatabase');

// not running the database on localhost? add a 4th parameter like this:
// $db->open('youruser', 'fancypass', 'holydatabase', 'pentagon.example.com');

// now there's two operation modes:
// the EASY one first
$objTable = $objConnector->table('themaintable');

// want a join?
// $objTable->join('anothertable');

// set a condition
$objTable->where('field', '=', 'value');

// there are some shortcuts, like this one:
// $objTable->eq('field', 'value');

// peek at the generated sql code
echo $objTable->sql() . '<br />';

// loop through the results and display them
for($i = 0; $i < $objTable->rows(); $i++) {
$arrRow = $objTable->next();
echo $arrRow['field'] . ' = ' . $arrRow['value'] . '<br />';
}

// you could also have got an object instead, like this:
// $objRow = $objTable->next(MONTY_NEXT_OBJECT);
// echo $objRow->field;


// you can also run raw SQL like this (the nerd mode):
$objConnector->query('SELECT * FROM themaintable WHERE field = "value"');
echo $objConnector->rows();


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

// load classes

$strDirectory = dirname(__file__);
$strDirectory = dirname(__file__) . '/classes/';

require_once $strDirectory.'/monty.class.php';
require_once $strDirectory.'/connector.class.php';
require_once $strDirectory.'/connector.mysql.class.php';
require_once $strDirectory.'/connector.mysql.easy.class.php';
require_once $strDirectory . 'monty.class.php';
require_once $strDirectory . 'connector.class.php';
require_once $strDirectory . 'connector.mysql.class.php';
require_once $strDirectory . 'connector.mysql.easy.class.php';

0 comments on commit 2353204

Please sign in to comment.