本文整理汇总了PHP中Database::pDataConnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::pDataConnect方法的具体用法?PHP Database::pDataConnect怎么用?PHP Database::pDataConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::pDataConnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalize
/**
localtranstoday used to be a view; recreate
it as a table if needed.
*/
public function normalize($db_name, $mode = BasicModel::NORMALIZE_MODE_CHECK, $doCreate = False)
{
if ($db_name == CoreLocal::get('pDatabase')) {
$this->connection = Database::pDataConnect();
} else {
if ($db_name == CoreLocal::get('tDatabase')) {
$this->connection = Database::tDataConnect();
} else {
echo "Error: Unknown database ({$db_name})";
return false;
}
}
if ($this->connection->isView($this->name)) {
if ($mode == BasicModel::NORMALIZE_MODE_CHECK) {
echo "View {$this->name} should be a table!\n";
echo "==========================================\n";
printf("%s table %s\n", "Check complete. Need to drop view & create replacement table.", $this->name);
echo "==========================================\n\n";
return 999;
} else {
$drop = $this->connection->query('DROP VIEW ' . $this->name);
echo "==========================================\n";
printf("Dropping view %s %s\n", $this->name, $drop ? "OK" : "failed");
if ($drop) {
$cResult = $this->create();
printf("Update complete. Creation of table %s %s\n", $this->name, $cResult ? "OK" : "failed");
}
echo "==========================================\n";
return true;
}
} else {
return parent::normalize($db_name, $mode, $doCreate);
}
}
示例2: parse
function parse($str)
{
$json = $this->default_json();
$arg = $this->left;
CoreLocal::set("sc", 1);
$staffID = substr($arg, 0, 4);
$pQuery = "select staffID,chargecode,blueLine from chargecodeview where chargecode = '" . $arg . "'";
$pConn = Database::pDataConnect();
$result = $pConn->query($pQuery);
$num_rows = $pConn->num_rows($result);
$row = $pConn->fetch_array($result);
if ($num_rows == 0) {
$json['output'] = DisplayLib::xboxMsg(_("unable to authenticate staff ") . $staffID, DisplayLib::standardClearButton());
CoreLocal::set("isStaff", 0);
// apbw 03/05/05 SCR
return $json;
} else {
CoreLocal::set("isStaff", 1);
// apbw 03/05/05 SCR
CoreLocal::set("memMsg", $row["blueLine"]);
$tQuery = "update localtemptrans set card_no = '" . $staffID . "', percentDiscount = 15";
$tConn = Database::tDataConnect();
$this->addscDiscount();
TransRecord::discountnotify(15);
$tConn->query($tQuery);
Database::getsubtotals();
$chk = self::ttl();
if ($chk !== True) {
$json['main_frame'] = $chk;
return $json;
}
CoreLocal::set("runningTotal", CoreLocal::get("amtdue"));
return self::tender("MI", CoreLocal::get("runningTotal") * 100);
}
}
示例3: errorCheck
/**
Check for errors
@return True or an error message string
*/
public function errorCheck()
{
$clearButton = array('OK [clear]' => 'parseWrapper(\'CL\');');
if (CoreLocal::get("isMember") != 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > CoreLocal::get("dollarOver") && CoreLocal::get("cashOverLimit") == 1) {
return DisplayLib::boxMsg(_("member check tender cannot exceed total purchase by over \$") . CoreLocal::get("dollarOver"), '', false, $clearButton);
} elseif (CoreLocal::get("store") == "wfc" && CoreLocal::get("isMember") != 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > 0) {
// This should really be a separate tender
// module for store-specific behavior
$db = Database::pDataConnect();
$q = sprintf("SELECT card_no FROM custReceiptMessage\n WHERE card_no=%d AND modifier_module='WfcEquityMessage'", CoreLocal::get('memberID'));
$r = $db->query($q);
if ($db->num_rows($r) > 0) {
return DisplayLib::xboxMsg(_("member check tender cannot exceed total purchase if equity is owed"), $clearButton);
}
// multi use
if (CoreLocal::get('standalone') == 0) {
$chkQ = "select trans_num from dlog \n where trans_type='T' and trans_subtype in ('CA','CK') \n and card_no=" . (int) CoreLocal::get('memberID') . "\n group by trans_num \n having sum(case when trans_subtype='CK' then total else 0 end) < 0 \n and sum(Case when trans_subtype='CA' then total else 0 end) > 0";
$db = Database::mDataConnect();
$chkR = $db->query($chkQ);
if ($db->num_rows($chkR) > 0) {
return DisplayLib::xboxMsg(_("already used check over benefit today"), $clearButton);
}
}
} elseif (CoreLocal::get("isMember") == 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > 0) {
$msg = _('Non-members may not write checks for more than the total purchase.');
return DisplayLib::xboxMsg($msg, $clearButton);
}
return true;
}
示例4: normalize
public function normalize($db_name, $mode = BasicModel::NORMALIZE_MODE_CHECK, $doCreate = False)
{
if ($db_name == CoreLocal::get('pDatabase')) {
$this->connection = Database::pDataConnect();
} else {
if ($db_name == CoreLocal::get('tDatabase')) {
$this->connection = Database::tDataConnect();
} else {
echo "Error: Unknown database ({$db_name})";
return false;
}
}
$viewSQL = $this->connection->getViewDefinition($this->name);
echo "==========================================\n";
printf("%s view %s\n", $mode == BasicModel::NORMALIZE_MODE_CHECK ? "Checking" : "Updating", "{$db_name}.{$this->name}");
echo "==========================================\n";
if (strstr($viewSQL, '0 AS memType') || strstr($viewSQL, '0 AS ' . $this->connection->identifier_escape('memType'))) {
/**
Structure-check 27Dec2013
Make sure memType is calcluated instead of hardcoded to zero
*/
echo "==========================================\n";
if ($mode == BasicModel::NORMALIZE_MODE_CHECK) {
echo "View needs to be rebuild to calculate memType correctly\n";
} else {
echo "Rebuilding view to calculate memType correctly... ";
$this->connection->query('DROP VIEW ' . $this->connection->identifier_escape($this->name));
$success = $this->create();
echo ($success ? 'succeeded' : 'failed') . "\n";
}
}
return 0;
}
示例5: testDatabase
public function testDatabase()
{
$db = Database::tDataConnect();
$this->assertInstanceOf('\\COREPOS\\pos\\lib\\SQLManager', $db);
$this->assertEquals(CoreLocal::get('tDatabase'), $db->default_db);
$db = Database::pDataConnect();
$this->assertInstanceOf('\\COREPOS\\pos\\lib\\SQLManager', $db);
$this->assertEquals(CoreLocal::get('pDatabase'), $db->default_db);
$this->assertEquals(1, Database::gettransno(-1));
// not a real emp_no
$db = Database::tDataConnect();
$matches = Database::localMatchingColumns($db, 'localtrans', 'localtemptrans');
$this->assertInternalType('string', $matches);
$this->assertRegExp('/(.+)/', $matches);
$globals = array('CashierNo' => 9999, 'cashier' => 'TRAINING', 'LoggedIn' => 0, 'TransNo' => 1, 'TTLFlag' => 0, 'FntlFlag' => 0, 'TaxExempt' => 0);
Database::setglobalvalues($globals);
$this->assertEquals(9999, CoreLocal::get('CashierNo'));
$this->assertEquals('TRAINING', CoreLocal::get('cashier'));
$this->assertEquals(0, CoreLocal::get('LoggedIn'));
$this->assertEquals(1, CoreLocal::get('transno'));
$this->assertEquals(0, CoreLocal::get('ttlflag'));
$this->assertEquals(0, CoreLocal::get('fntlflag'));
$this->assertEquals(0, CoreLocal::get('TaxExempt'));
Database::loadglobalvalues();
// reload session from db. shouldn't change.
$this->assertEquals(9999, CoreLocal::get('CashierNo'));
$this->assertEquals('TRAINING', CoreLocal::get('cashier'));
$this->assertEquals(0, CoreLocal::get('LoggedIn'));
$this->assertEquals(1, CoreLocal::get('transno'));
$this->assertEquals(0, CoreLocal::get('ttlflag'));
$this->assertEquals(0, CoreLocal::get('fntlflag'));
$this->assertEquals(0, CoreLocal::get('TaxExempt'));
Database::setglobalvalue('TTLFlag', 1);
Database::loadglobalvalues();
$this->assertEquals(1, CoreLocal::get('ttlflag'));
Database::setglobalflags(0);
Database::loadglobalvalues();
$this->assertEquals(0, CoreLocal::get('ttlflag'));
$this->assertEquals(0, CoreLocal::get('fntlflag'));
if (!class_exists('lttLib')) {
include dirname(__FILE__) . '/lttLib.php';
}
lttLib::clear();
$record = lttLib::genericRecord();
$record['upc'] = '0000000000000';
$record['description'] = uniqid('TEST-');
TransRecord::addRecord($record);
SuspendLib::suspendorder();
$db = Database::mDataConnect();
$query = "\n SELECT *\n FROM suspended\n WHERE upc='{$record['upc']}'\n AND description='{$record['description']}'\n AND datetime >= " . $db->curdate();
$result = $db->query($query);
$this->assertNotEquals(false, $result, 'Could not query suspended record');
$this->assertEquals(1, $db->num_rows($result), 'Could not find suspended record');
$row = $db->fetch_row($result);
$this->assertInternalType('array', $row, 'Invalid suspended record');
foreach ($record as $column => $value) {
$this->assertArrayHasKey($column, $row, 'Suspended missing ' . $column);
$this->assertEquals($value, $row[$column], 'Suspended mismatch on column ' . $column);
}
}
示例6: body_content
/**
Build a <select> form that submits
back to this script
*/
function body_content()
{
$db = Database::pDataConnect();
$q = "SELECT dept_no,dept_name FROM departments ORDER BY dept_name";
$r = $db->query($q);
echo "<div class=\"baseHeight\">" . "<div class=\"listbox\">" . "<form name=\"selectform\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\"" . " id=\"selectform\">" . "<select name=\"search\" id=\"search\" " . ' style="min-height: 200px; min-width: 220px;" ' . "size=\"15\" onblur=\"\$('#search').focus();\">";
$selected = "selected";
while ($row = $db->fetch_row($r)) {
echo "<option value='" . $row["dept_no"] . "' " . $selected . ">";
// ­ prevents the cursor from moving out of
// step with filter-as-you-type
echo '­ ' . $row['dept_name'];
echo '</option>';
$selected = "";
}
echo "</select>" . '<div id="filter-div"></div>' . "</div>";
if (CoreLocal::get('touchscreen')) {
echo '<div class="listbox listboxText">' . DisplayLib::touchScreenScrollButtons() . '</div>';
}
echo "<div class=\"listboxText coloredText centerOffset\">" . _("use arrow keys to navigate") . '<p><button type="submit" class="pos-button wide-button coloredArea">
OK <span class="smaller">[enter]</span>
</button></p>' . '<p><button type="submit" class="pos-button wide-button errorColoredArea"
onclick="$(\'#search\').append($(\'<option>\').val(\'\'));$(\'#search\').val(\'\');">
Cancel <span class="smaller">[clear]</span>
</button></p>' . "</div><!-- /.listboxText coloredText .centerOffset -->" . "</form>" . "<div class=\"clear\"></div>";
echo "</div>";
$this->add_onload_command("selectSubmit('#search', '#selectform', '#filter-div')\n");
$this->add_onload_command("\$('#search').focus();\n");
}
示例7: body_content
/**
Build a <select> form that submits
back to this script
*/
function body_content()
{
$db = Database::pDataConnect();
$q = "SELECT TenderCode,TenderName FROM tenders \n WHERE MaxAmount > 0\n ORDER BY TenderName";
$r = $db->query($q);
echo "<div class=\"baseHeight\">" . "<div class=\"listbox\">" . "<form name=\"selectform\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\"" . " id=\"selectform\">" . "<select name=\"search\" id=\"search\" " . "size=\"15\" onblur=\"\$('#search').focus();\">";
$selected = "selected";
while ($row = $db->fetch_row($r)) {
echo "<option value='" . $row["TenderCode"] . "' " . $selected . ">";
echo $row['TenderName'];
echo '</option>';
$selected = "";
}
echo "</select>" . "</div>";
if (CoreLocal::get('touchscreen')) {
echo '<div class="listbox listboxText">' . DisplayLib::touchScreenScrollButtons() . '</div>';
}
echo "<div class=\"listboxText coloredText centerOffset\">";
if (CoreLocal::get("tenderTotal") >= 0) {
echo _("tendering") . ' $';
} else {
echo _("refunding") . ' $';
}
printf('%.2f', abs(CoreLocal::get("tenderTotal")) / 100);
echo '<br />';
echo _("use arrow keys to navigate") . '<p><button type="submit" class="pos-button wide-button coloredArea">
OK <span class="smaller">[enter]</span>
</button></p>' . '<p><button type="submit" class="pos-button wide-button errorColoredArea"
onclick="$(\'#search\').append($(\'<option>\').val(\'\'));$(\'#search\').val(\'\');">
Cancel <span class="smaller">[clear]</span>
</button></p>' . "</div><!-- /.listboxText coloredText .centerOffset -->" . "</form>" . "<div class=\"clear\"></div>";
echo "</div>";
$this->add_onload_command("selectSubmit('#search', '#selectform')\n");
$this->add_onload_command("\$('#search').focus();\n");
}
示例8: preprocess
function preprocess()
{
// check for posts before drawing anything, so we can redirect
if (isset($_REQUEST['reginput'])) {
$input = strtoupper(trim($_REQUEST['reginput']));
// CL always exits
if ($input == "CL") {
PaycardLib::paycard_reset();
CoreLocal::set("msgrepeat", 1);
CoreLocal::set("strRemembered", 'TO');
CoreLocal::set("toggletax", 0);
CoreLocal::set("togglefoodstamp", 0);
$this->change_page($this->page_url . "gui-modules/pos2.php");
return False;
}
$continue = false;
// when voiding tenders, the input must be an FEC's passcode
if (CoreLocal::get("paycard_mode") == PaycardLib::PAYCARD_MODE_VOID && $input != "" && substr($input, -2) != "CL") {
$db = Database::pDataConnect();
if (Authenticate::checkPermission($input, 11)) {
CoreLocal::set("adminP", $input);
$continue = true;
}
}
// when voiding items, no code is necessary, only confirmation
if (CoreLocal::get("paycard_mode") != PaycardLib::PAYCARD_MODE_VOID && $input == "") {
$continue = true;
}
// go?
if ($continue) {
// send the request, then disable the form
$this->add_onload_command('paycard_submitWrapper();');
$this->action = "onsubmit=\"return false;\"";
}
// if we're still here, display prompt again
} else {
if (CoreLocal::get("paycard_mode") == PaycardLib::PAYCARD_MODE_AUTH) {
// call paycard_void on first load to set up
// transaction and check for problems
$id = CoreLocal::get("paycard_id");
foreach (CoreLocal::get("RegisteredPaycardClasses") as $rpc) {
$myObj = new $rpc();
if ($myObj->handlesType(CoreLocal::get("paycard_type"))) {
$ret = $myObj->paycard_void($id);
if (isset($ret['output']) && !empty($ret['output'])) {
CoreLocal::set("boxMsg", $ret['output']);
$this->change_page($this->page_url . "gui-modules/boxMsg2.php");
return False;
}
break;
}
}
}
}
return True;
}
示例9: parse
public function parse($str)
{
$my_url = MiscLib::base_url();
$split = explode("DP", $str);
$dept = $split[1];
$amt = $split[0];
if (strstr($amt, '.')) {
$amt = round($amt * 100);
}
$ret = $this->default_json();
/**
This "if" is the new addition to trigger the
department select screen
*/
if (empty($split[1])) {
// no department specified, just amount followed by DP
// maintain refund if needed
if (CoreLocal::get("refund")) {
$amt = "RF" . $amt;
}
// save entered amount
CoreLocal::set("departmentAmount", $amt);
// go to the department select screen
$ret['main_frame'] = $my_url . 'gui-modules/deptlist.php';
} else {
if (CoreLocal::get("refund") == 1 && CoreLocal::get("refundComment") == "") {
if (CoreLocal::get("SecurityRefund") > 20) {
$ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=RefundAdminLogin";
} else {
$ret['main_frame'] = $my_url . 'gui-modules/refundComment.php';
}
CoreLocal::set("refundComment", CoreLocal::get("strEntered"));
}
}
/* apply any appropriate special dept modules */
$deptmods = CoreLocal::get('SpecialDeptMap');
$db = Database::pDataConnect();
if (!is_array($deptmods) && $db->table_exists('SpecialDeptMap')) {
$model = new \COREPOS\pos\lib\models\op\SpecialDeptMapModel($db);
$deptmods = $model->buildMap();
CoreLocal::set('SpecialDeptMap', $deptmods);
}
$index = (int) ($dept / 10);
if (is_array($deptmods) && isset($deptmods[$index])) {
foreach ($deptmods[$index] as $mod) {
$obj = new $mod();
$ret = $obj->handle($dept, $amt / 100, $ret);
}
}
if (!$ret['main_frame']) {
$ret = PrehLib::deptkey($amt, $dept, $ret);
}
return $ret;
}
示例10: search
public function search($str)
{
$ret = array();
$sql = Database::pDataConnect();
$query = "select upc, description, normal_price, special_price, " . "scale from products where " . "description like '%" . $str . "%' " . "and inUse='1' " . "order by description";
$result = $sql->query($query);
while ($row = $sql->fetch_row($result)) {
$ret[$row['upc']] = $row;
}
return $ret;
}
示例11: lookup_by_text
public function lookup_by_text($text)
{
$dbc = Database::pDataConnect();
$query = $dbc->prepare_statement('SELECT CardNo, personNum,
LastName, FirstName FROM custdata
WHERE LastName LIKE ?
AND Type = \'INACT\'
ORDER BY LastName, FirstName');
$result = $dbc->exec_statement($query, array($text . '%'));
return $this->resultToArray($dbc, $result);
}
示例12: overlayKeys
private function overlayKeys($number)
{
$db = Database::pDataConnect();
$my_keys = array();
if ($db->table_exists('QuickLookups')) {
$prep = $db->prepare('
SELECT label,
action
FROM QuickLookups
WHERE lookupSet = ?
ORDER BY sequence');
$res = $db->execute($prep, array($number));
while ($row = $db->fetch_row($res)) {
$my_keys[] = new quickkey($row['label'], $row['action']);
}
}
if (count($my_keys) == 0) {
include dirname(__FILE__) . '/quickkeys/keys/' . $number . '.php';
}
if (count($my_keys) == 0) {
return DisplayLib::boxMsg('Menu not found', '', false, DisplayLib::standardClearButton());
}
$clearButton = false;
$ret = '';
for ($i = 0; $i < count($my_keys); $i++) {
if ($i % 3 == 0) {
if ($i != 0) {
$ret .= ' </div>';
}
$ret .= '<div class="qkRow">';
}
$ret .= sprintf('
<div class="qkBox">
<div id="qkDiv%d">
<button type="button" class="quick_button pos-button coloredBorder"
onclick="$(\'#reginput\').val($(\'#reginput\').val()+\'%s\');submitWrapper();">
%s
</button>
</div>
</div>', $i, $my_keys[$i]->output_text, $my_keys[$i]->title);
}
if (!$clearButton) {
$ret .= '<div class="qkBox">
<div>
<button type="button" class="quick_button pos-button errorColoredArea"
onclick="$(\'#reginput\').val(\'CL\');submitWrapper();">
Clear <span class="smaller">[clear]</span>
</button>
</div>
</div>';
}
$ret .= '</div>';
return $ret;
}
示例13: successfully
/**
Apply action
@return [boolean] true if the action
completes successfully (or is not
necessary at all) or [string] url
to redirect to another page for
further decisions/input.
*/
public function apply()
{
$db = Database::pDataConnect();
$repeat = CoreLocal::get('msgrepeat');
$coupons = array();
$hc_table = $db->table_definition('houseCoupons');
if ($db->table_exists('autoCoupons')) {
$autoR = $db->query('SELECT coupID, description FROM autoCoupons');
while ($autoW = $db->fetch_row($autoR)) {
$coupons[$autoW['coupID']] = $autoW['description'];
}
}
if (isset($hc_table['description']) && isset($hc_table['auto'])) {
$autoR = $db->query('SELECT coupID, description FROM houseCoupons WHERE auto=1');
while ($autoW = $db->fetch_row($autoR)) {
$coupons[$autoW['coupID']] = $autoW['description'];
}
}
$hc = new HouseCoupon();
$prefix = CoreLocal::get('houseCouponPrefix');
if ($prefix == '') {
$prefix = '00499999';
}
foreach ($coupons as $id => $description) {
if ($hc->checkQualifications($id, true) !== true) {
// member or transaction does not meet requirements
// for auto-coupon purposes, this isn't really an
// error. no feedback necessary
continue;
}
// get value of coupon AND value
// of any previous applications of this coupon
$add = $hc->getValue($id);
$upc = $prefix . str_pad($id, 5, '0', STR_PAD_LEFT);
$upc = str_pad($upc, 13, '0', STR_PAD_LEFT);
$current = $db->query('SELECT SUM(-total) AS ttl FROM ' . CoreLocal::get('tDatabase') . $db->sep() . 'localtemptrans
WHERE upc=\'' . $upc . '\'');
$val = 0;
if ($db->num_rows($current) > 0) {
$currentW = $db->fetch_row($current);
$val = $currentW['ttl'];
}
$next_val = $add['value'] - $val;
if ($next_val == 0) {
// no need to add another line item
// previous one(s) sum to correct total
continue;
}
TransRecord::addhousecoupon($upc, $add['department'], -1 * $next_val, $description);
}
CoreLocal::set('msgrepeat', $repeat);
return true;
}
示例14: testSampleData
public function testSampleData()
{
$samples = array('couponcodes', 'custdata', 'departments', 'employees', 'globalvalues', 'houseCoupons', 'houseCouponItems', 'MasterSuperDepts', 'parameters', 'products', 'subdepts', 'tenders');
$dbc = Database::pDataConnect();
foreach ($samples as $sample) {
ob_start();
$dbc->query('TRUNCATE TABLE ' . $dbc->identifier_escape($sample));
$loaded = InstallUtilities::loadSampleData($dbc, $sample, false);
$output = ob_get_clean();
$this->assertEquals(true, $loaded, 'Error with sample data for ' . $sample . ' (' . $output . ')');
}
}
示例15: errorCheck
/**
Check for errors
@return True or an error message string
*/
public function errorCheck()
{
if (MiscLib::truncate2(CoreLocal::get("amtdue")) < MiscLib::truncate2($this->amount)) {
return DisplayLib::xboxMsg(_("store transfer exceeds purchase amount"), DisplayLib::standardClearButton());
}
$db = Database::pDataConnect();
$query = 'SELECT chargeOk FROM custdata WHERE chargeOk=1 AND CardNo=' . CoreLocal::get('memberID');
$result = $db->query($query);
if ($db->num_rows($result) == 0) {
return DisplayLib::xboxMsg(_("member cannot make transfers"), DisplayLib::standardClearButton());
}
return true;
}