本文整理汇总了PHP中DB::get_results方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::get_results方法的具体用法?PHP DB::get_results怎么用?PHP DB::get_results使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::get_results方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showCupones
function showCupones()
{
$database = new DB();
echo "\n <table class=\"table table-striped table-bordered bootstrap-datatable datatable\">\n <thead>\n\t\t\t<tr>\n <th> </th>\n\t\t\t <th>Cupon</th>\n\t\t\t <th>Compra Minima</th>\n\n\t\t\t <th>Tipo</th>\n\t\t\t <th>Opciones</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>";
$query = "SELECT * from cupon,cupontipo\n where cupon.cupontipo_id=cupontipo.cupontipo_id";
$results = $database->get_results($query);
$i = 0;
foreach ($results as $row) {
$i += 1;
echo "<tr>\n\t\t\t <td align=right><font > {$i} </td>\n\t\t\t <td ><a href=\"/index.php?data=cupones&op=generados&bulk=" . $row['bulk'] . "\" >";
switch ($row['cupontipo_id']) {
case 1:
echo "\$ " . dinero($row['cantidad']) . " MX";
break;
case 2:
echo $row['cantidad'] . " %";
break;
}
echo "</b><a>\n\t\t\t </td>";
echo "<td><font >" . dinero($row['compra_minima']) . "</td>\n\n\t\t\t<td> <font >" . strtoupper($row['cupontipo']) . "</td>";
echo "<td><button class=\"btn-primary btn-setting hidden-print\" onclick=\"showData('myModal',\n 'view/cupones/cupones_agregar.inc.php',\n 'f=editar&cuid=" . $row['cupon_id'] . "')\">Editar</button>\n\n <button class=\"btn-info btn-setting hidden-print\" onclick=\"showData('myModal',\n 'view/cupones/cupones.php',\n 'f=generar&cuid=" . $row['cupon_id'] . "&cupon=" . $row['cupon'] . "&monto=" . $row['cantidad'] . "&compra_minima=" . $row['compra_minima'] . "')\">Generar</button></td>";
echo "</tr>";
}
echo " </tbody>\n </table>";
}
示例2: mostrar_transacciones
function mostrar_transacciones($fecha_inicio, $fecha_fin, $user)
{
$database = new DB();
//$fecha=fechaplusweek($fecha);
$total_pagos = ceil($total / $abono);
echo "\n\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table class=\"table table-condensed striped\" width=100% >\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Id</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Fecha</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Movimiento</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Total</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Cliente</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead>\n\t\t\t\t\t\t\t <tbody>";
$fecha_inicio_bd = $fecha_inicio;
$fecha_fin_bd = $fecha_fin;
$query = "SELECT * from movimiento,tipomov,admin,cliente\n\t\twhere movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.admin_id=admin.admin_id AND (movimiento.tipomov_id=1 OR movimiento.tipomov_id=13 or movimiento.tipomov_id=14)\n AND movimiento.cliente_id=cliente.cliente_id AND cliente.empresa_id=0";
if ($fecha_inicio) {
$query .= " AND fecha>='{$fecha_inicio_bd}' AND fecha<='{$fecha_fin_bd} 23:59:59' ";
}
if ($user) {
$query .= " AND movimiento.admin_id={$user} ";
}
$query .= " ORDER BY fecha DESC";
$results = $database->get_results($query);
foreach ($results as $item) {
$vendedor = $item['nombre'] . " " . $item['apellidop'];
echo "<tr><td style='text-align:right' width=30 >" . $item['movimiento_id'] . "</td>\n\t\t\t\t\t\t<td style='text-align:center'><span class='hidden-desktop'>" . fechamysqltous($item['fecha']) . "</span><a class='hidden-print' href=/index.php?data=estadisticas&op=ventas&fi=" . fechamysqltous($fecha_inicio) . "&hi={$hi}&ff=" . fechamysqltous($fecha_fin) . "&hf={$hf}&fid=" . $item['factura_id'] . ">" . fechamysqltomx($item['fecha'], "letra") . "</a></td>\n\t\t\t\t\t\t\t<td style='text-align:center'>" . $item['tipomov'] . "\n\t\t\t\t\t\t\t<br></td>\n\t\t\t\t\t\t\t<td style='text-align:right'>\$ " . dinero($item['cantidad'] + $item['iva']) . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $vendedor;
echo " </td></tr>";
$n++;
}
echo " </tbody>\n\t\t</table> ";
//echo "Pagos Atrazados: ".$pagos_atrazados;
echo "</div>";
}
示例3: catalogo
function catalogo($tid, $i)
{
$database = new DB();
$query = "SELECT categoria_id,categoria FROM categoria\n\t\twhere 1 ";
$results = $database->get_results($query);
foreach ($results as $row) {
echo "<tr ><td colspan=3>" . $row['categoria'] . " </td></tr>";
$query = "SELECT descuento from temporada where temporada_Id={$tid}";
list($descuento) = $database->get_row($query);
$query = "SELECT subcategoria_id,subcategoria FROM subcategoria where categoria_id=" . $row['categoria_id'];
$subs = $database->get_results($query);
foreach ($subs as $sub) {
$query = "SELECT count(producto_id) as productos FROM producto\n\t\t\t\t\twhere producto.temporada_id={$tid} AND subcategoria_id=" . $sub['subcategoria_id'];
if ($i) {
$query .= " AND producto.descuento={$descuento}";
} else {
$query .= " AND producto.descuento<>{$descuento}";
}
list($productos) = $database->get_row($query);
if ($productos) {
echo "<tr><td></td><td align=right>\n\t\t\t\t\t\t<a href=/index.php?data=catalogo&subcat=" . $sub['subcategoria_id'] . "&tid={$tid}>" . $sub['subcategoria'] . "</a>\n </td>\n\t\t\t\t\t\t<td>{$productos}</td></tr>";
}
}
}
}
示例4: filter_optimize_database
public function filter_optimize_database($result, $paramarray)
{
$space_saved = 0;
$tables = 0;
switch (DB::get_driver_name()) {
case 'mysql':
$q = 'SHOW TABLE STATUS WHERE data_free > 0';
$tables = DB::get_results($q);
if (count($tables) > 0) {
foreach ($tables as $table) {
$q2 = 'OPTIMIZE TABLE ' . $table->Name;
if (DB::query($q2)) {
$space_saved += $table->Data_free;
$tables++;
}
}
EventLog::log('Database Tables Optimized. ' . Utils::human_size($space_saved) . ' reclaimed from ' . HabariLocale::_n('table', 'tables', $tables) . '.');
}
$result = true;
break;
case 'sqlite':
if (DB::exec('VACUUM')) {
$result = true;
EventLog::log('SQLite database VACUUM\'ed successfully.');
} else {
$result = false;
}
break;
default:
$result = false;
break;
}
return $result;
}
示例5: action_hconsole_debug
public function action_hconsole_debug()
{
if (isset($this->code['debug'])) {
ob_start();
$res = eval($this->code['debug']);
$dat = ob_get_contents();
ob_end_clean();
if ($res === false) {
throw Error::raise($dat, E_COMPILE_ERROR);
} else {
echo $this->htmlspecial ? htmlspecialchars($dat) : $dat;
}
}
if ($this->sql) {
$itemlist = array();
if (preg_match('#^\\s*(select|show).*#i', $this->sql)) {
$data = DB::get_results($this->sql);
if (DB::has_errors()) {
throw Error::raise(DB::get_last_error());
}
if (is_array($data) && count($data)) {
self::sql_dump($data);
} else {
echo 'empty set, nothing returned.';
}
} else {
$data = DB::query($this->sql);
if (DB::has_errors()) {
throw Error::raise(DB::get_last_error());
}
echo 'Result: ' . (string) $data;
}
}
}
示例6: testTimesAdded
public function testTimesAdded()
{
$sql = 'SELECT `flighttime`
FROM ' . TABLE_PREFIX . 'pireps
WHERE `accepted`=' . PIREP_ACCEPTED;
$results = DB::get_results($sql);
if (!$results) {
$this->markTestSkipped('No PIREPs to test against');
}
$this->added_time = 0;
foreach ($results as $row) {
$this->added_time = Util::AddTime($this->added_time, $row->flighttime);
}
$this->assertNotEqual(0, $this->added_time);
// Now calculate by PIREP
$allpilots = PilotData::GetAllPilots();
$total = 0;
foreach ($allpilots as $pilot) {
$p_hours = PilotData::getPilotHours($pilot->pilotid);
$total = Util::AddTime($total, $p_hours);
}
$this->assertNotEqual(0, $total);
$this->assertEqual($total, $this->added_time);
StatsData::UpdateTotalHours();
$this->assertEqual($total, StatsData::TotalHours());
}
示例7: action_ajax_auto_tags
/**
* Respond to Javascript callbacks
* The name of this method is action_ajax_ followed by what you passed to the context parameter above.
*/
public function action_ajax_auto_tags( $handler )
{
$selected = array();
if( isset( $handler->handler_vars['selected'] ) ) {
$selected = Utils::single_array( $handler->handler_vars['selected'] );
}
if( isset( $handler->handler_vars['term'] ) && MultiByte::strlen( $handler->handler_vars['term'] ) ) {
$search = $handler->handler_vars['term'] . '%';
$tags = new Terms( DB::get_results( "SELECT * FROM {terms} WHERE vocabulary_id = :vid and LOWER(term_display) LIKE LOWER(:crit) ORDER BY term_display ASC", array( 'vid' => Tags::vocabulary()->id, 'crit' => $search ), 'Term' ) );
}
else {
$tags = Tags::vocabulary()->get_tree( 'term_display ASC' );
}
$resp = array();
foreach ( $tags as $tag ) {
$resp[] = MultiByte::strpos( $tag->term_display, ',' ) === false ? $tag->term_display : $tag->tag_text_searchable;
}
if( count( $selected ) ) {
$resp = array_diff($resp, $selected );
}
// Send the response
// $ar = new AjaxResponse();
// $ar->data = $resp;
// $ar->out();
echo json_encode( $resp );
}
示例8: _load
/**
* Populate the internal hashmap with the values from the DB.
*/
protected function _load()
{
if ($this->_loaded == true) {
return;
}
if (empty($this->_key_value)) {
$this->_loaded == true;
return;
}
// This InfoRecord is read-only?
if (empty($this->_table_name)) {
$this->_loaded == true;
return;
}
$result = DB::get_results('
SELECT name, value, type
FROM ' . $this->_table_name . '
WHERE ' . $this->_key_name . ' = ?', array($this->_key_value));
foreach ($result as $result_element) {
// XXX is this logic right?
if ($result_element->type == 1) {
$this->__inforecord_array[$result_element->name] = array('value' => unserialize($result_element->value));
} else {
$this->__inforecord_array[$result_element->name] = array('value' => $result_element->value);
}
}
$this->_loaded = true;
}
示例9: testTimesAdded
public function testTimesAdded()
{
echo '<h3>Checking Times</h3>';
$sql = 'SELECT `flighttime`
FROM ' . TABLE_PREFIX . 'pireps
WHERE `accepted`=' . PIREP_ACCEPTED;
$results = DB::get_results($sql);
$this->added_time = 0;
foreach ($results as $row) {
$this->added_time = Util::AddTime($this->added_time, $row->flighttime);
}
heading('Time added, all PIREPS at once');
$this->assertNotEqual(0, $this->added_time);
heading('Time added, pilot by pilot');
// Now calculate by PIREP
$allpilots = PilotData::GetAllPilots();
$total = 0;
foreach ($allpilots as $pilot) {
$p_hours = PilotData::getPilotHours($pilot->pilotid);
$total = Util::AddTime($total, $p_hours);
}
$this->assertNotEqual(0, $total);
heading('Comparing pilot to pilot vs all PIREPS');
$this->assertEqual($total, $this->added_time);
heading('Compare to STAT total hours');
StatsData::UpdateTotalHours();
$this->assertEqual($total, StatsData::TotalHours());
echo '<br />';
}
示例10: filter_rssblocks_update
public function filter_rssblocks_update($success, $force = false)
{
EventLog::log('Running rrsblocks update');
$blocks = DB::get_results('SELECT b.* FROM {blocks} b WHERE b.type = ?', array('rssblock'), 'Block');
Plugins::act('get_blocks', $blocks);
$success = true;
foreach ($blocks as $block) {
$cachename = array('rssblock', md5($block->feed_url));
if ($force || Cache::expired($cachename)) {
$r = new RemoteRequest($block->feed_url);
$r->set_timeout(10);
$r->execute();
$feed = $r->get_response_body();
try {
if (is_string($feed)) {
new SimpleXMLElement($feed);
// This throws an exception if the feed isn't valid
Cache::set($cachename, $feed, 3600, true);
}
} catch (Exception $e) {
$success = false;
}
}
}
Session::notice('ran rssblocks update');
return $success;
}
示例11: GetCustomFields
/**
* Get all of the custom fields that will show up
* during the registration
*/
public static function GetCustomFields($getall = false)
{
$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'customfields';
if ($getall == false) {
$sql .= ' WHERE showonregister=1';
}
return DB::get_results($sql);
}
示例12: getAllFields
/**
* Return all of the custom fields data
*/
public static function getAllFields()
{
$all_fields = CodonCache::read('allfields');
if ($all_fields === false) {
$all_fields = DB::get_results('SELECT * FROM ' . TABLE_PREFIX . 'customfields');
CodonCache::write('allfields', $all_fields, 'long');
}
return $all_fields;
}
示例13: GetDownloads
/**
* Get all of the downloads in a certain category
*
* @param int $categoryid the ID of the category
* @return array Array of objects of all the downloads
*
*/
public static function GetDownloads($categoryid)
{
if ($categoryid == '') {
return false;
}
$categoryid = intval($categoryid);
$sql = 'SELECT * FROM ' . TABLE_PREFIX . 'downloads
WHERE pid=' . $categoryid;
return DB::get_results($sql);
}
示例14: optimizeTables
public static function optimizeTables()
{
$tables = Config::Get('TABLE_LIST');
foreach ($tables as $key => $name) {
$tables[$key] = '`' . TABLE_PREFIX . $name . '`';
}
$tables = implode(', ', $tables);
$sql = 'OPTIMIZE TABLE ' . $tables;
return DB::get_results($sql);
}
示例15: list_logentry_types
/**
* Returns an associative array of LogEntry types
*
* @param bool whether to force a refresh of the cached values
* @return array An array of log entry type names => integer values
*/
public static function list_logentry_types($force = false)
{
if ($force || empty(self::$types)) {
self::$types = array();
$res = DB::get_results('SELECT id, module, type FROM {log_types}');
foreach ($res as $x) {
self::$types[$x->module][$x->type] = $x->id;
}
}
return self::$types;
}