/**
  * Retourne une liste d'accessoires selon des paramètres donnés.
  *
  * @param array $params
  * @param boolean $count_only
  * @return object recordset/integer
  */
 public function getAccessories($params = array(), $count_only = false)
 {
     $reqPlus = '';
     if (!empty($params['id'])) {
         $reqPlus .= ' AND a.id=' . (int) $params['id'] . ' ';
     }
     if (!empty($params['product_id'])) {
         $reqPlus .= ' AND a.product_id=' . (int) $params['product_id'] . ' ';
     }
     if (isset($params['active'])) {
         if ($params['active'] == 0) {
             $reqPlus .= 'AND a.active=0 ';
         } elseif ($params['active'] == 1) {
             $reqPlus .= 'AND a.active=1 ';
         } elseif ($params['active'] == 2) {
             $reqPlus .= '';
         }
     } else {
         $reqPlus .= 'AND a.active=1 ';
     }
     if ($count_only) {
         $query = 'SELECT COUNT(a.id) AS num_accessories ' . 'FROM ' . $this->t_accessories . ' AS a ' . 'LEFT JOIN ' . $this->t_products . ' AS p ON p.id=a.product_id ' . 'WHERE 1 ' . $reqPlus;
     } else {
         $query = 'SELECT a.id, a.product_id, a.active, a.title, ' . 'p.title AS product_title ' . 'FROM ' . $this->t_accessories . ' AS a ' . 'LEFT JOIN ' . $this->t_products . ' AS p ON p.id=a.product_id ' . 'WHERE 1 ' . $reqPlus;
         if (!empty($params['order'])) {
             $query .= 'ORDER BY ' . $params['order'] . ' ';
         } else {
             $query .= 'ORDER BY p.title ASC, a.title ASC ';
         }
         if (!empty($params['limit'])) {
             $query .= 'LIMIT ' . $params['limit'] . ' ';
         }
     }
     if (($rs = $this->db->select($query)) === false) {
         if ($count_only) {
             return 0;
         } else {
             return new recordset(array());
         }
     }
     if ($count_only) {
         return (int) $rs->num_accessories;
     } else {
         return $rs;
     }
 }
 /**
  * Retourne une liste de produits selon des paramètres donnés.
  *
  * @param array $params
  * @param boolean $count_only
  * @return object recordset/integer
  */
 public function getProducts($params = array(), $count_only = false)
 {
     $reqPlus = '';
     if (!empty($params['id'])) {
         $reqPlus .= ' AND p.id=' . (int) $params['id'] . ' ';
     }
     if (isset($params['active'])) {
         if ($params['active'] == 0) {
             $reqPlus .= 'AND p.active=0 ';
         } elseif ($params['active'] == 1) {
             $reqPlus .= 'AND p.active=1 ';
         } elseif ($params['active'] == 2) {
             $reqPlus .= '';
         }
     } else {
         $reqPlus .= 'AND p.active=1 ';
     }
     if ($count_only) {
         $query = 'SELECT COUNT(p.id) AS num_products ' . 'FROM ' . $this->t_products . ' AS p ' . 'WHERE 1 ' . $reqPlus;
     } else {
         $query = 'SELECT p.id, p.active, p.title ' . 'FROM ' . $this->t_products . ' AS p ' . 'WHERE 1 ' . $reqPlus;
         if (!empty($params['order'])) {
             $query .= 'ORDER BY ' . $params['order'] . ' ';
         } else {
             $query .= 'ORDER BY p.title ASC ';
         }
         if (!empty($params['limit'])) {
             $query .= 'LIMIT ' . $params['limit'] . ' ';
         }
     }
     if (($rs = $this->db->select($query)) === false) {
         if ($count_only) {
             return 0;
         } else {
             return new recordset(array());
         }
     }
     if ($count_only) {
         return (int) $rs->num_products;
     } else {
         return $rs;
     }
 }
<?php

// a_authordetails.php -- Admin view Author Details
include './functions.php';
require_once './config/auth.php';
require './config/config.php';
include "./classes/mysql.class.php";
$mysqldb = new mysql();
$mysqldb->connect();
$mysqldb->select();
$authorid = mifi($_REQUEST[aid]);
$mysqldb->query("SELECT CONCAT(FirstName, ' ', LastName) AS name, Approved, UserName, Email, DATE_FORMAT(RegistrationDate, '%M %d, %Y') AS dr, (SELECT count(*) from articles WHERE Approved = 'N' AND AuthorID='{$authorid}') AS PendingArticles, (SELECT count(*) from articles WHERE Approved = 'Y' AND AuthorID='{$authorid}') AS ApprovedArticles, (SELECT count(*) from articles WHERE Approved = 'S' AND AuthorID='{$authorid}') AS SavedArticles FROM authors WHERE AuthorID='{$authorid}'");
$row = $mysqldb->fetchObject();
$totalarticles = $row->ApprovedArticles + $row->PendingArticles + $row->SavedArticles;
if (isset($_REQUEST['newperms'])) {
    $title = 'Permissions Updated';
} else {
    $title = 'Author details for ' . $row->name . ' (' . $row->UserName . ')';
}
$approved = $row->Approved;
if ($approved != 'Y') {
    $approved = "<a href=\"aufe2a.php?aid={$authorid}\">{$row->Approved}</a>";
}
head_page($title);
menu_options($title, $vnum, $viewop, $pid, $keys, $adfl);
contentinit($title);
echo <<<_AUTHORDETAILS
AuthorID : {$authorid}<br />
UserName : {$row->UserName}<br />
Full Name : {$row->name}<br />
Permissions : {$row->Approved}<br>
function addtag($id)
{
    if (!$id) {
        exit;
    }
    $mysqldb = new mysql();
    $mysqldb->connect();
    $mysqldb->select();
    $mysqldb->query("SELECT Keyw FROM articles WHERE FileID='{$id}'");
    $row = $mysqldb->fetchObject();
    $keystotags = $row->Keyw;
    // place keywords into tags table.
    $arrkeywords = explode(' ', $keystotags);
    foreach ($arrkeywords as $keyword) {
        if (strlen($keyword) > 4) {
            $mysqldb->query("INSERT INTO tags (fileid, tag) VALUES ('{$fileid}', '{$keyword}')");
        }
    }
}
示例#5
0
 public static function get($table, $idFields = null)
 {
     $select = self::$select;
     self::$select = '*';
     if ($idFields === null) {
         return self::query("SELECT {$select} FROM {$table}");
     } else {
         $idString = implode(' AND ', self::quoteArray($idFields, true));
         return self::query("SELECT {$select} FROM {$table} WHERE {$idString}");
     }
 }
include_once 'classes/class.pager.php';
$db = new mysql();
$pager = new paginator();
mysql_query("SET NAMES 'utf8'");
$currentPage = $_REQUEST["page"];
$pageLimit = 200;
if ($currentPage == 0) {
    $currentPage = 1;
}
$limitFrom = $pageLimit * $currentPage - $pageLimit;
switch ($_REQUEST['f']) {
    //Save category function
    case 'save_category':
        $save_category = $db->insert_sql("INSERT INTO categories (title) VALUES ('" . $_REQUEST['category_title'] . "')");
        echo "<option value=''>Select Category</option>";
        $category_sql = $db->select("SELECT title FROM categories ORDER BY title ASC");
        while ($category = mysql_fetch_object($category_sql)) {
            echo "<option value='" . $category->title . "'>" . $category->title . "</option>";
        }
        break;
        //Save location function
    //Save location function
    case 'save_location':
        $location = array();
        $location['location'] = $_REQUEST['location_title'];
        $location['city'] = $_REQUEST['city_title'];
        $db->insert_array("locations", $location);
        echo "<span class='location_res'></span>";
        break;
        //Get locations based on the city
    //Get locations based on the city
示例#7
0
<?php

require 'msql.class.php';
// include mysql-class
$dbObj = new mysql('mysql.metropolia.fi', 'dineshs', 'password2043', 'dineshs');
// make an object from mysql-class
// make the connection
$dbObj->connect();
$dbObj->select();
?>
 
示例#8
0
 /**
  * @covers ITE\mysql::select
  */
 public function testSelect()
 {
     $this->assertCount(1, $this->object->select("log", "1=1", "log_id DESC LIMIT 1", false, false));
     $this->assertFalse($this->object->select("dummyTable", "1=1", "log_id DESC LIMIT 1", false, false));
 }