Esempio n. 1
0
	function get_recs()
	{
		$dbh = dbops::getpdo();
		$field_list = join(",",$this->select_fields);
		$where_clause = $this->where_clause;
		if (empty($where_clause) and !empty($this->where_keys_vals))
		{
			$where_clause_ar = array();
			foreach ($this->where_keys_vals as $key => $val)
			{
				$where_clause_ar[] = $key."=:".$key;
			}
			$where_clause = " WHERE " . join(" AND ",$where_clause_ar);
		}
		$sql = join(" ", array($this->select_clause ,
									 $field_list,
									 $this->from_clause,
									 $where_clause,
									 $this->order_by,
									 $this->limit_clause)); 
		$stmt = $dbh->prepare($sql);
		foreach($this->where_keys_vals as $key => $val)
		{
			$stmt->bindParam(":".$key,$val);
		}
		$stmt->execute() or die("an error occurred: GenericDBDS,get_recs+846645410");
		return $stmt->fetchAll();
	}
Esempio n. 2
0
	function max_reached()
	{
		$dbh = dbops::getpdo();
		$stmt = $dbh->prepare("SELECT COUNT(*) FROM entity_grouping WHERE eg_type=:eg_type");
		$stmt->bindParam(":eg_type",$this->grouping_type);
		$stmt->execute() or die("an error occurred: EntityGrouping,+8465410");
		$result = $stmt->fetchColumn();
		return ($result >= AppSettings::gv("NumGroupedItemsType".$this->grouping_type."Max")) ? 1 : 0;
	}
Esempio n. 3
0
	function set_approved_value($approved_value)
	{
		$dbh = dbops::getpdo();
		$stmt = $dbh->prepare("UPDATE medb_order set approved = :approved where order_id = :order_id");
		$stmt->bindParam(":approved",$approved_value);
		$stmt->bindParam(":order_id",$this->order_id);
		$stmt->execute() or die("an error occurred: medb_order,83kjf641sl8890");
		return 1;
	}
Esempio n. 4
0
 public function test_mysql($loop_times, $sql = NULL)
 {
     $tbname = $this->tbname;
     $dbname = $this->dbname;
     $start_time = microtime(true);
     if ($sql == NULL) {
         $sql = sprintf("select * from %s", $ops->getTBname());
     }
     for ($i = 0; $i < $loop_times; $i++) {
         $ops = new dbops();
         $ops->setTBname($tbname);
         $ops->setDBname($dbname);
         ##$start=$i*rand(1,950);  # more then 2w
         $start = $i * 128;
         $conditions = sprintf("idx > %d and idx < %d;", $start, $start + 1000);
         $sql = sprintf("select * from %s where %s", $tbname, $conditions);
         $data = $ops->query($sql);
         $ops->close();
     }
     $end_time = microtime(true);
     $dbtime = $end_time - $start_time;
     return $dbtime;
 }
Esempio n. 5
0
<?php

/***
 * this main.php is main process and call other
 * class and functions
 */
#require_once('mysql_info.php');
require_once 'dbops.php';
require_once 'iredis.php';
echo "数据库测试页面\n <br/>";
date_default_timezone_set('PRC');
echo "当前时间:" . date("Y-m-d H:i:s") . "<br/>";
echo "数据库表如下:<br/>";
## following show the mysql database operation
$ops = new dbops();
#$ops->setDBname("greentea");    # change database
#$ops->setTBname("light_app");
$sql = sprintf("select * from %s", $ops->getTBname());
$data = $ops->query($sql);
$ops->close();
## show the $data in a form
$rows = count($data);
$cols = count($data[0]) / 2;
# two kinds of index: id and type
#$cols=count($data[0]);
$td_width = floor(100 / $cols) . "%";
$tab_str = "<table border=\"1\" width=\"80%\" align=\"left\">\n";
var_dump($data);
for ($i = 0; $i < $rows; $i++) {
    $tab_str .= "<tr>\n";
    $row_i = $data[$i];