PHP Classes

File: example_3.php

Recommend this page to a friend!
  Packages of Bogdan Lupandin   MySQL Access Wrapper   example_3.php   Download  
File: example_3.php
Role: Example script
Content type: text/plain
Description: Example of generating an SQL statement
Class: MySQL Access Wrapper
MySQL database access wrapper
Author: By
Last change:
Date: 17 years ago
Size: 1,171 bytes
 

Contents

Class file image Download
<p>Generating an SQL statement from an array...</p>
<pre><code>
require_once "db.php";

$db = new db();

$sql = array(
             'SELECT'    => '*',
             'FROM'      => '`database`.`table`',
             'JOIN'      => '`table2',
             'ON'        => '`table1`.`field1` = `table2`.`field2`',
             'WHERE'     => array(
                            '`field1`' => 'value1',
                            '`field2`' => 'value2'),
             'ORDER BY'  => '`field2`',
             'ASC'       => null
);

echo $db->build_key_query($sql);
</code></pre>
<br />
<p>Results in:</p>
<blockquote>
<?php
require_once "db.php";

$db = new db();

$sql = array(
             'SELECT'    => '*',
             'FROM'      => '`database`.`table`',
             'JOIN'      => '`table2',
             'ON'        => '`table1`.`field1` = `table2`.`field2`',
             'WHERE'     => array(
                            '`field1`' => 'value1',
                            '`field2`' => 'value2'),
             'ORDER BY'  => '`field2`',
             'ASC'       => null
);

echo $db->build_key_query($sql);
?></blockquote>