PHP Classes
elePHPant
Icontem

File: example_1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Bogdan Lupandin  >  MySQL Access Wrapper  >  example_1.php  >  Download  
File: example_1.php
Role: Example script
Content type: text/plain
Description: Example of generating the INSERT/UPDATE statement
Class: MySQL Access Wrapper
MySQL database access wrapper
Author: By
Last change:
Date: 6 years ago
Size: 1,224 bytes
 

Contents

Class file image Download
<p>Creating the INSERT and UPDATE statements... Code used to generate them are...</p>
<pre><code>
require_once "db.php";
$db = new db();

$sql = array(
    'col_1' => 'val_1',
    'col_2' => 'val_2',
    'col_3' => 'val_3',
    'col_4' => 'val_4'
);


$insert = $db->build_insert('table', $sql);

$sql = array(
    'col_1' => 'val_4',
    'col_2' => 'val_3',
    'col_3' => 'val_2',
    'col_4' => 'val_1'
);

$where = array(
    'col_5' => 'val_60',
    'col_60' => 'val_5'
);

$update = $db->build_update('table', $sql, $where);

echo &lt;&lt;&lt;EOT
$insert
&lt;br />
&lt;br />
$update
EOT;
</code></pre>
<br />
<p>Results in:</p>
<blockquote>
<?php
require_once "db.php";
$db = new db();

$sql = array(
   
'col_1' => 'val_1',
   
'col_2' => 'val_2',
   
'col_3' => 'val_3',
   
'col_4' => 'val_4'
);


$insert = $db->build_insert('table', $sql);

$sql = array(
   
'col_1' => 'val_4',
   
'col_2' => 'val_3',
   
'col_3' => 'val_2',
   
'col_4' => 'val_1'
);

$where = array(
   
'col_5' => 'val_60',
   
'col_60' => 'val_5'
);

$update = $db->build_update('table', $sql, $where);

echo <<<EOT
$insert
<br />
<br />
$update
EOT;

?></blockquote>