Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pineapple Technologies  >  EZ Select  >  example1.php  >  Download  
File: example1.php
Role: ???
Content type: text/plain
Description: example 1
Class: EZ Select
Author: By
Last change:
Date: 2002-02-15 00:03
Size: 924 bytes
 

Contents

Class file image Download
<?php
// example1.php
//
// using EZ Select to generate queries based on some user input.

require("ez_select.php");

$my_query = new ez_select();

// we want to select from "foo" and "bar" tables
$my_query->add_table("foo");
$my_query->add_table("bar");

// add the fields we want to select
$my_query->add_field("foo.id");
$my_query->add_field("foo.name");
$my_query->add_field("bar.id");

// where clauses to restrict our query
$my_query->add_where_clause("foo.id = bar.id");
$my_query->add_where_clause("foo.name != 'foobar'");

// order by foo.id, then RAND()
$my_query->add_order_by("foo.id");
$my_query->add_order_by("RAND()");

$my_query->set_order_type("ASC");

// get first 25 results
$my_query->set_limit(0, 25);

// show our query
$my_query->show();

// at this point you would run the query through mysql_query() or whatever
// $result = mysql_query( $my_query->make() );

?>