本文整理汇总了PHP中ADODB_mysqli::qstr方法的典型用法代码示例。如果您正苦于以下问题:PHP ADODB_mysqli::qstr方法的具体用法?PHP ADODB_mysqli::qstr怎么用?PHP ADODB_mysqli::qstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADODB_mysqli
的用法示例。
在下文中一共展示了ADODB_mysqli::qstr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* {@inheritdoc}
* @see Scalr\Upgrade.AbstractEntity::save()
*/
public function save()
{
$pk = $this->getPrimaryKey();
$actual = $this->getActual();
$new = !$actual->{$pk};
if ($new && empty($this->{$pk})) {
throw new UpgradeException('%s has not been provided yet for class %s', $pk, get_class($this));
}
$set = "";
foreach ($this->getChanges() as $prop => $value) {
if ($prop == 'hash' || $prop == 'uuid') {
$qstr = "UNHEX(" . $this->db->qstr($value) . ")";
} else {
$qstr = $this->db->qstr($value);
}
$set .= ",`" . $prop . "` = " . $qstr;
}
if (!empty($set)) {
$stmt = ($new ? "INSERT" : "UPDATE") . " `" . UpgradeHandler::DB_TABLE_UPGRADES . "`\n SET " . ltrim($set, ',') . "\n " . (!$new ? "WHERE `" . $pk . "` = UNHEX(" . $this->db->qstr($this->{$pk}) . ")" : "");
$this->db->Execute($stmt);
//Synchronizes actual state of the entity
$this->getChanges()->synchronize();
}
}
示例2: hasTableReferencedColumn
/**
* (non-PHPdoc)
* @see \Scalr\Upgrade\UpdateInterface::hasTableReferencedColumn()
*/
public function hasTableReferencedColumn($referencedTable, $referencedColumn, $referencedSchema = null)
{
$row = $this->db->GetRow("\n SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE s\n WHERE s.REFERENCED_TABLE_SCHEMA = " . (isset($referencedSchema) ? $this->db->qstr($referencedSchema) : "DATABASE()") . "\n AND s.REFERENCED_TABLE_NAME = ?\n AND s.REFERENCED_COLUMN_NAME = ?\n LIMIT 1\n ", array($referencedTable, $referencedColumn));
return isset($row['CONSTRAINT_NAME']) ? true : false;
}
示例3: buildResponseFromSql
protected function buildResponseFromSql($sql, $filterFields = array(), $groupSQL = "", $simpleQuery = true, $noLimit = false)
{
$this->request->defineParams(array('start' => array('type' => 'int', 'default' => 0), 'limit' => array('type' => 'int', 'default' => 20)));
if (is_array($groupSQL)) {
return $this->buildResponseFromSql2($sql, $filterFields, $groupSQL, is_array($simpleQuery) ? $simpleQuery : array(), $noLimit);
}
if ($this->getParam('query') && count($filterFields) > 0) {
$filter = $this->db->qstr('%' . trim($this->getParam('query')) . '%');
foreach ($filterFields as $field) {
if ($simpleQuery) {
$likes[] = "`{$field}` LIKE {$filter}";
} else {
$likes[] = "{$field} LIKE {$filter}";
}
}
$sql .= " AND (";
$sql .= implode(" OR ", $likes);
$sql .= ")";
}
if ($groupSQL) {
$sql .= "{$groupSQL}";
}
if (!$noLimit) {
$response['total'] = $this->db->GetOne('SELECT COUNT(*) FROM (' . $sql . ') c_sub');
}
// @TODO replace with simple code (legacy code)
$s = $this->getParam('sort');
if (!is_array($s)) {
$s = json_decode($this->getParam('sort'), true);
}
if (is_array($s)) {
$sorts = array();
if (count($s) && (!isset($s[0]) || !is_array($s[0]))) {
$s = array($s);
}
foreach ($s as $param) {
$sort = preg_replace("/[^A-Za-z0-9_]+/", "", $param['property']);
$dir = in_array(strtolower($param['direction']), array('asc', 'desc')) ? $param['direction'] : 'ASC';
if ($sort && $dir) {
$sorts[] = "`{$sort}` {$dir}";
}
}
if (count($sorts) > 0) {
$sql .= " ORDER BY " . implode($sorts, ',');
}
} else {
if ($this->getParam('sort')) {
$sort = preg_replace("/[^A-Za-z0-9_]+/", "", $this->getParam('sort'));
$dir = in_array(strtolower($this->getParam('dir')), array('asc', 'desc')) ? $this->getParam('dir') : 'ASC';
$sql .= " ORDER BY `{$sort}` {$dir}";
}
}
if (!$noLimit) {
$start = intval($this->getParam('start'));
if ($start > $response["total"]) {
$start = 0;
}
$limit = intval($this->getParam('limit'));
$sql .= " LIMIT {$start}, {$limit}";
}
//$response['sql'] = $sql;
$response["success"] = true;
$response["data"] = $this->db->GetAll($sql);
return $response;
}
示例4: hasPriceForUrl
/**
* Checks whether there is some price for specified platform and url
*
* @param string $platform Cloud platform
* @param string $url The endpoint url
* @param string $cloudLocation optional The cloud location
* @return bool Returns TRUE if there is some price for specified platform and url or FALSE otherwise
*/
public function hasPriceForUrl($platform, $url, $cloudLocation = null)
{
$res = $this->cadb->getOne("\n SELECT EXISTS(\n SELECT 1 FROM `price_history`\n WHERE `platform` = ? AND url = ?\n " . (!empty($cloudLocation) ? "AND cloud_location = " . $this->cadb->qstr($cloudLocation) : "") . "\n ) AS `val`\n ", [$platform, empty($url) ? '' : $this->normalizeUrl($url)]);
return !!$res;
}
示例5: getFarmData
/**
* Gets cost metering data
*
* @param string $accountId Client identifier
* @param array $criteria Filter array. ['fieldName' => 'fieldValue'] or ['fieldName' => ['value1', 'value2']]
* @param DateTime $begin Begin date
* @param DateTime $end End date
*
* @param array|string $breakdown optional The identifier of the tag or list
* looks like ['day', TagEntity::TAG_ID_FARM ...]
* The interval to group data [12 hours, day, week, month]
*
* @param bool $rawResult optional Whether it should return raw result
*
* @return AggregationCollection|array Returns collection or array with raw result
* @throws InvalidArgumentException
*/
public function getFarmData($accountId, array $criteria, DateTime $begin, DateTime $end, $breakdown = null, $rawResult = false)
{
$now = new DateTime("now", new DateTimeZone('UTC'));
$usageHourly = false;
if ($end > $now) {
$end = $now;
}
if (!$begin instanceof DateTime || !$end instanceof DateTime) {
throw new InvalidArgumentException(sprintf("Both Start end End time should be instance of DateTime."));
}
if ($breakdown !== null) {
if (!is_array($breakdown)) {
$breakdown = [$breakdown];
}
if (in_array('hour', $breakdown)) {
$usageHourly = true;
}
}
if (isset($criteria['hourly'])) {
$usageHourly = true;
unset($criteria['hourly']);
}
$selectFields = "SUM(`u`.`cost`) AS `cost`, `u`.`cloud_location`, `u`.`platform`, `u`.`project_id`, `u`.`account_id`, `u`.`env_id`";
if ($usageHourly) {
$obj = new UsageHourlyEntity();
if ($breakdown !== null) {
$selectFields .= ", MIN(`u`.`num`) AS `min_usage`, MAX(`u`.`num`) AS `max_usage`,";
} else {
$selectFields .= ", `u`.`num` AS `min_usage`, `u`.`num` AS `max_usage`,";
}
$selectFields .= "`u`.`num` AS `usage_hours`, 1 AS `working_hours`";
$dtime = 'dtime';
} else {
$obj = new FarmUsageDailyEntity();
if ($breakdown !== null) {
$selectFields .= ", MIN(`u`.`min_usage`) AS `min_usage`, MAX(`u`.`max_usage`) AS `max_usage`, SUM(`u`.`usage_hours`) AS `usage_hours`, SUM(`u`.`working_hours`) AS `working_hours`";
} else {
$selectFields .= ", `u`.`min_usage`, `u`.`max_usage`, `u`.`usage_hours`, `u`.`working_hours`";
}
$dtime = 'date';
}
$aFields = ['cost', 'projectId', 'minUsage', 'maxUsage', 'cloudLocation', 'usageHours', 'workingHours', 'platform', 'accountId', 'envId'];
$where = ' u.account_id = ' . $this->cadb->escape($accountId);
$it = $obj->getIterator();
$getValue = function (Field $field, $value) {
$value = $field->type->toDb($value);
if ($field->getType() instanceof UuidType) {
$value = "UNHEX(" . $this->cadb->qstr($value) . ")";
}
return $value;
};
foreach ($criteria as $name => $value) {
$field = $it->getField($name);
if (is_null($field)) {
throw new InvalidArgumentException(sprintf("Invalid field name: %s", $name));
}
if (!is_array($value)) {
$where .= ' AND ' . $field->getColumnName('u') . '=' . $getValue($field, $value);
} else {
$values = [];
$operator = 'IN';
if (count($value) == 1) {
list($k, $v) = each($value);
if ($k === '$in') {
$operator = 'IN';
$value = $v;
} elseif ($k === '$nin') {
$operator = 'NOT IN';
$value = $v;
}
}
foreach ($value as $val) {
$values[] = $getValue($field, $val);
}
$where .= ' AND ' . $field->getColumnName('u') . $operator . " ('" . implode("','", $values) . "')";
}
}
//Group rules according to ChartPeriodIterator
$groupFields = ['hour' => [true, "`u`.`date` `period`", null], 'day' => [true, "DATE(`u`.`date`) `period`", null], 'week' => [true, "YEARWEEK(`u`.`date`, 0) `period`", null], 'month' => [true, "DATE_FORMAT(`u`.`date`, '%Y-%m') `period`", null], 'year' => [true, "YEAR(`u`.`date`) `period`", null], TagEntity::TAG_ID_ENVIRONMENT => ['envId', 'u'], TagEntity::TAG_ID_PLATFORM => ['platform', 'u'], TagEntity::TAG_ID_FARM => ['farmId', 'u'], TagEntity::TAG_ID_FARM_ROLE => ['farmRoleId', 'u'], TagEntity::TAG_ID_PROJECT => ['projectId', 'u'], 'cloudLocation' => ['cloudLocation', 'u'], 'usageItem' => ['name', 'ui'], 'usageType' => ['id', 'ut'], 'distributionType' => ['costDistrType', 'ut']];
$group = '';
$join = '';
$subtotals = [];
if (!empty($breakdown)) {
//.........这里部分代码省略.........
示例6: showTables
/**
* List all tables or tables which names match a RegExp
*
* @param string $match optional Regex to match tables
* @return array List of matching tables
*/
public function showTables($match = null)
{
$tables = [];
$stm = "SHOW TABLES";
if (!empty($match)) {
$stm .= " WHERE Tables_in_" . $this->db->GetOne("SELECT DATABASE()") . " REGEXP " . $this->db->qstr($match);
}
$res = $this->db->Execute($stm);
while ($row = $res->FetchRow()) {
list(, $tables[]) = each($row);
}
return $tables;
}