当前位置: 首页>>代码示例>>PHP>>正文


PHP connection::query方法代码示例

本文整理汇总了PHP中connection::query方法的典型用法代码示例。如果您正苦于以下问题:PHP connection::query方法的具体用法?PHP connection::query怎么用?PHP connection::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在connection的用法示例。


在下文中一共展示了connection::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: AddProduct

function AddProduct($config, $jsonResult)
{
    $cargo_id = $_GET["cargo_id"];
    $kind_id = "";
    $kind = $_GET["kind"];
    $amount = $_GET["amount"];
    $sql1 = "SELECT COUNT(name) as kind_amount , kind_id FROM kind WHERE name = '" . $kind . "';";
    $sql2 = "INSERT INTO kind(name) VALUES('" . $kind . "')";
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $result1 = $conn->query($sql1);
        foreach ($result1 as $row) {
            if ($row['kind_amount'] === "0") {
                $conn->query($sql2);
                $kind_id = $conn->conn->lastInsertId();
            } else {
                $kind_id = $row['kind_id'];
            }
        }
        $conn->query("INSERT INTO product(cargo_id , amount , kind_id) VALUES(" . $cargo_id . " , " . $amount . " , " . $kind_id . ")");
        $product_id = $conn->conn->lastInsertId();
        $jsonResult->json_data['result_data'] = $product_id;
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:27,代码来源:addProduct.php

示例2: getCargoListWithKinds

function getCargoListWithKinds($config, $jsonResult)
{
    $conn = new connection(new Config(null, null));
    $result = array();
    $cargoes = $conn->query("SELECT * FROM cargo");
    foreach ($cargoes as $cargo) {
        $kinds = $conn->query("SELECT DISTINCT kind.name\n                FROM product INNER JOIN kind on product.kind_id = kind.kind_id\n                WHERE cargo_id =" . $cargo['cargo_id']);
        $kinds = $kinds->fetchAll();
        array_push($result, array('name' => $cargo['name'], 'kinds' => $kinds));
    }
    $jsonResult->json_data['result_data'] = $result;
}
开发者ID:dakusinio,项目名称:Sale,代码行数:12,代码来源:getCargoListWithKinds.php

示例3: connection

    function has_items($id)
    {
        $db = new connection();
        $db->query('SELECT * FROM object WHERE type="page" AND status=1 AND parent_id=' . $id);
        if ($this->has_child($id)) {
            ?>
<ul class="submenu">
<?php 
        }
        while ($result = $db->fetch_array()) {
            ?>
<li><a href='./?page_id=<?php 
            echo $result['id'];
            ?>
'><?php 
            echo $result['menu_title'];
            ?>
</a>
<?php 
            if ($this->has_items($result['id'])) {
                echo $this->has_items($result['id']);
            }
            ?>
</li>
<?php 
        }
        if ($this->has_child($id)) {
            ?>
</ul>
<?php 
        }
    }
开发者ID:zarat,项目名称:Simplepress,代码行数:32,代码来源:class_navigation.php

示例4: RemoveAuction

function RemoveAuction($config, $jsonResult)
{
    $id = $_GET['auction_id'];
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    $conn->query("DELETE FROM allegro where auction_id='" . $id . "';");
}
开发者ID:dakusinio,项目名称:Sale,代码行数:7,代码来源:removeAuction.php

示例5: connection

 function the_cat($by_name = null, $linked = null)
 {
     if ($this->is_object()) {
         if (!empty($this->cat)) {
             // Gibt die ID der Kategorie zurück
             if (null == $by_name) {
                 return $this->cat;
                 // Gibt den Titel der Kategorie zurück
             } else {
                 $db = new connection();
                 $get_the_catname = $db->query('SELECT * FROM object WHERE id=' . $this->cat);
                 $the_catname = $db->fetch_array();
                 if (null !== $linked) {
                     // Kategorie wird als Link ausgegeben
                     return '<a href="./?cat=' . $the_catname['id'] . '" rel="nofollow">' . $the_catname['title'] . '</a> ';
                 } else {
                     // Kategorie wird nicht als Link ausgegeben
                     return $the_catname['title'] . " ";
                 }
             }
         } else {
             return false;
         }
     }
 }
开发者ID:zarat,项目名称:Simplepress,代码行数:25,代码来源:class_object.php

示例6: getProductList

function getProductList($kind_name)
{
    $productsWithPhotos = array();
    $conn = new connection(new Config(null, null));
    $products = $conn->query("SELECT product_id , amount , kind.name as kind\nFROM product INNER JOIN kind on product.kind_id = kind.kind_id\nWHERE kind.name = '" . $kind_name . "';");
    print $conn->error;
    foreach ($products as $product) {
        $tmp_photos = array();
        $photos = $conn->query("SELECT photo.photo_id as id, photo.extension\n                from product inner join photo on product.product_id = photo.product_id\n                where product.product_id = '" . $product['product_id'] . "';");
        foreach ($photos as $photo) {
            array_push($tmp_photos, new Photo($photo['id'], $photo['extension']));
        }
        array_push($productsWithPhotos, new Product($product['product_id'], $product['kind'], $product['amount'], $tmp_photos));
    }
    return $productsWithPhotos;
}
开发者ID:dakusinio,项目名称:Sale,代码行数:16,代码来源:getProductForPresentation.php

示例7: getCargoListWithKinds

function getCargoListWithKinds($config, $jsonResult)
{
    $kind_name = $_GET['kind_name'];
    $productsWithPhotos = array();
    $conn = new connection($config);
    $products = $conn->query("SELECT product_id , amount , kind.name as kind\nFROM product INNER JOIN kind on product.kind_id = kind.kind_id\nWHERE kind.name = '" . $kind_name . "';");
    print $conn->error;
    foreach ($products as $product) {
        $tmp_photos = array();
        $photos = $conn->query("SELECT photo.photo_id as id, photo.extension\n                from product inner join photo on product.product_id = photo.product_id\n                where product.product_id = '" . $product['product_id'] . "';");
        foreach ($photos as $photo) {
            array_push($tmp_photos, new Photo($photo['id'], $photo['extension']));
        }
        array_push($productsWithPhotos, new Product($product['product_id'], $product['kind'], $product['amount'], $tmp_photos));
    }
    $jsonResult->json_data['result_data'] = $productsWithPhotos;
}
开发者ID:dakusinio,项目名称:Sale,代码行数:17,代码来源:getProductForPresentation2.php

示例8: RemoveProduct

function RemoveProduct($config, $jsonResult)
{
    $conn = new connection($config);
    $product_id = $_GET['product_id'];
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $conn->query("DELETE FROM product WHERE product_id=" . $product_id . ";");
        $result = $conn->query("SELECT photo_id , extension FROM photo WHERE product_id = " . $product_id . ";");
        foreach ($result as $row) {
            $photo_id = $row['$photo_id'];
            unlink('../images/' . $photo_id . '.' . $row['extension']);
            $conn->query("DELETE FROM photo WHERE photo_id = " . $photo_id . ";");
        }
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:17,代码来源:removeProduct.php

示例9: GetAuctionList

function GetAuctionList($config, $jsonResult)
{
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    $result = $conn->query("SELECT auction_id , name , sandbox FROM allegro;");
    foreach ($result as $row) {
        array_push($jsonResult->json_data['result_data'], array('id' => $row['auction_id'], 'name' => $row['name'], 'sandbox' => $row['sandbox']));
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:9,代码来源:getAuctionList.php

示例10: GetCargoName

function GetCargoName($config, $jsonResult)
{
    $cargo_id = $_GET['cargo_id'];
    $conn = new connection($config);
    $result = $conn->query("SELECT name FROM cargo WHERE cargo_id = " . $cargo_id . ";");
    foreach ($result as $row) {
        array_push($jsonResult->json_data["result_data"], $row['name']);
    }
    $jsonResult->json_data["result_code"] = JSON::$resultCodes['ok'];
}
开发者ID:dakusinio,项目名称:Sale,代码行数:10,代码来源:getCargoName.php

示例11: AddCargo

function AddCargo($config, $jsonResult)
{
    $name = $_GET['name'];
    $conn = new connection($config);
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $conn->query("INSERT INTO cargo(name) VALUES('" . $name . "');");
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:11,代码来源:addCargo.php

示例12: GetProductList

function GetProductList($config, $jsonResult)
{
    $cargo_id = $_GET['cargo_id'];
    $conn = new connection($config);
    $result = $conn->query("SELECT kind.name as kind_name , amount , product_id\n            from product\n            inner join kind on product.kind_id = kind.kind_id\n            inner join cargo on product.cargo_id = cargo.cargo_id\n            where cargo.cargo_id = '" . $cargo_id . "'\n            ORDER BY kind.name;");
    $kinds = array();
    foreach ($result as $row) {
        $tmp_photos = array();
        $result2 = $conn->query("SELECT photo.photo_id , photo.extension\n                from product inner join photo on product.product_id = photo.product_id\n                where product.product_id = '" . $row['product_id'] . "';");
        foreach ($result2 as $row2) {
            array_push($tmp_photos, new Photo($row2['photo_id'], $row2['extension']));
        }
        array_push($kinds, new Product($row['product_id'], $row['kind_name'], $row['amount'], $tmp_photos));
    }
    $jsonResult->json_data['result_data'] = $kinds;
    if ($result->rowCount() === 0) {
        $jsonResult->json_data["result_code"] = JSON::$resultCodes['no_product'];
    } else {
        $jsonResult->json_data["result_code"] = JSON::$resultCodes['ok'];
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:21,代码来源:getProductList.php

示例13: AddItems

function AddItems($config, $jsonResult)
{
    $conn = new connection($config);
    $product_id = $_GET['product_id'];
    $amount = $_GET['amount'];
    $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    try {
        $conn->query("UPDATE product SET amount = amount + " . $amount . " WHERE product_id = " . $product_id);
    } catch (PDOException $e) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['mysql_exception'];
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:12,代码来源:addItems.php

示例14: load

 public function load($iRecordID)
 {
     $oCon = new connection();
     $sSQL = "SELECT RecordID, Title, Artist, Price, GenreID, PhotoPath\n\t\t\t\tFROM tbrecords \n\t\t\t\tWHERE RecordID = " . $iRecordID;
     $oResultSet = $oCon->query($sSQL);
     $aRow = $oCon->fetchArray($oResultSet);
     $this->iRecordID = $aRow['RecordID'];
     $this->sTitle = $aRow['Title'];
     $this->sArtist = $aRow['Artist'];
     $this->fPrice = $aRow['Price'];
     $this->iGenreID = $aRow['GenreID'];
     $this->iPhotoPath = $aRow['PhotoPath'];
     $oCon->close();
 }
开发者ID:wasim01,项目名称:theRecordBreakers,代码行数:14,代码来源:record.php

示例15: GetCargoList

function GetCargoList($config, $jsonResult)
{
    $conn = new connection($config);
    $result = $conn->query("SELECT\n                            COUNT(DISTINCT kind_id) as kind_amount ,\n                            COUNT(product_id) as product_amount ,\n                            SUM(amount) as item_amount,\n                            cargo.cargo_id,\n                            cargo.name as cargo_name\n                            FROM product\n                            RIGHT JOIN cargo on product.cargo_id = cargo.cargo_id\n                            GROUP BY cargo.name\n                            ORDER BY cargo.cargo_id;");
    print $conn->error;
    foreach ($result as $row) {
        array_push($jsonResult->json_data["result_data"], array('kind_amount' => $row['kind_amount'], 'product_amount' => $row['product_amount'], 'item_amount' => $row['item_amount'], 'cargo_id' => $row['cargo_id'], 'cargo_name' => $row['cargo_name']));
    }
    if ($result->rowCount() === 0) {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['no_cargoes'];
    } else {
        $jsonResult->json_data['result_code'] = JSON::$resultCodes['ok'];
    }
}
开发者ID:dakusinio,项目名称:Sale,代码行数:14,代码来源:getCargoList.php


注:本文中的connection::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。