From 88600c94ef744f284f871da8482900f3d0bb00f8 Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Sat, 4 Jun 2005 09:53:17 +0000 Subject: [PATCH] Don't set boolean SQL values to '1' directly, use abstraction layer instead. --- lib/documentmanagement/Document.inc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/documentmanagement/Document.inc b/lib/documentmanagement/Document.inc index 13725dd..37ef8f0 100644 --- a/lib/documentmanagement/Document.inc +++ b/lib/documentmanagement/Document.inc @@ -535,11 +535,18 @@ class Document extends KTEntity { $aDocumentFieldArray; settype($aDocumentFieldArray,"array"); $sql = $default->db; - $result = $sql->query(array("SELECT DF.id AS id, DF.name AS name, DF.data_type AS data_type " ./*ok*/ - "FROM $default->document_fields_table AS DF " . - "INNER JOIN $default->document_type_fields_table AS DTFL ON DF.id = DTFL.field_id " . - "WHERE DTFL.document_type_id = ? " . ($bMandatoryOnly ? "AND DFTL.is_mandatory = 1 " : " ") . - "ORDER BY DF.name ASC", $iDocumentTypeID)); + $sQuery = "SELECT DF.id AS id, DF.name AS name, DF.data_type AS data_type " ./*ok*/ + "FROM $default->document_fields_table AS DF " . + "INNER JOIN $default->document_type_fields_table AS DTFL ON DF.id = DTFL.field_id " . + "WHERE DTFL.document_type_id = ? "; + $aParams = array($iDocumentTypeID); + if ($bMandatoryOnly) { + $sQuery .= "AND DFTL.is_mandatory = ? "; + $aParams[] = true; + } + $sQuery .= "ORDER BY DF.name ASC"; + $result = $sql->query(array($sQuery, $aParams)); + if ($result) { $iCount = 0; while ($sql->next_record()) { -- libgit2 0.21.4