<?php
include_once('inc.config.php');
// if you like this class please rate it on
// http://www.phpclasses.org/package/5283-PHP-Simple-MySQL-database-access-wrapper.html#ratings
// not necessary but I put it in so you know it exists
$db->set_contype(0); # 0 = default (regular), 1 = peristent, 2 = persistent with compression, 3 = regular with compression
// $db->q // insert or update
$sql = "INSERT INTO tablename (name, email) VALUES ('bob', 'user@email.com') ";
$id = $db->q($sql);
// $db->row // fetch a single row
$sql = "SELECT name, email FROM tablename";
$data = $db->r($sql);
# $data["name"] would equal 'bob'
# $data["email"] would equal 'user@email.com'
// $db->get // fetch an array
$sql = "SELECT name, email FROM tablename";
$rows = $db->get($sql);
# would return an array of multiple rows which you could traverse as such...
if(is_array($rows))
{
foreach($rows as $row)
{
# $row["name"] would equal 'bob'
# $row["email"] would equal 'user@email.com'
}
}
# NEW!
// $db->insert_from_array($table, $arr) // insert from an array
$table = 'tblorderpcs';
$arr = array (
"order_id" => $jobid,
"pcs_name" => $sname,
"pcs_qty" => $sqty,
"pcs_pn" => $spn,
"pcs_estimate" => $sest,
"pcs_memo" => $smemo,
"ship_id" => $ship_id,
"pcs_tstamp" => $time
);
$id = $db->insert_from_array($table, $arr);
// $db->update_from_array($table, $arr, $extra); // update from an array
$table = 'tblorderpcs';
$extra = "WHERE jID = $subjobid LIMIT 1";
$arr = array (
"pcs_name" => $sname,
"pcs_qty" => $sqty,
"pcs_pn" => $spn,
"pcs_estimate" => $sest,
"pcs_memo" => $smemo,
"ship_id" => $ship_id,
"pcs_made" => $smade,
"pcs_wasted"=> $swasted,
"pcs_ppu" => $sppu
);
return $db->update_from_array($table, $arr, $extra);
// you can force close the connection by calling. Not necessary
// and if you perform another query after this it will automagically
// reopen the connection.
$db->close();
?>
|