コード例 #1
0
    /**
     * Count InventoryLocations
     * by InventoryModelId Index(es)
     * @param integer $intInventoryModelId
     * @return int
     */
    public static function CountByInventoryModelIdLocations($intInventoryModelId)
    {
        // Call to ArrayQueryHelper to Get Database Object and Get SQL Clauses
        InventoryLocation::QueryHelper($objDatabase);
        // Properly Escape All Input Parameters using Database->SqlVariable()
        $intInventoryModelId = $objDatabase->SqlVariable($intInventoryModelId, true);
        // Setup the SQL Query
        $strQuery = sprintf('
				SELECT
					COUNT(*) AS row_count
				FROM
					`inventory_location`
				WHERE
					`inventory_model_id` %s
					AND `inventory_location`.`location_id` > 5', $intInventoryModelId);
        // Perform the Query and Return the Count
        $objDbResult = $objDatabase->Query($strQuery);
        $strDbRow = $objDbResult->FetchRow();
        return QType::Cast($strDbRow[0], QType::Integer);
    }