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