manual query not coreectly instatiated

thread: 2 messages  |  last: about 2 years ago  |  started: monday, january 11, 2010, 6:07 am pst


#1  |  flunki (Rathlau, Germany) Germany
Monday, January 11, 2010, 6:07 AM PST

Hi Forum,

I habe the following manual query:

public static function LoadArrayByLike ($strSuche, $strOrderBy = null, $strLimit = null, $objExpansionMap = null) {
           // Call to ArrayQueryHelper to Get Database Object and Get SQL Clauses

           Funktion::ArrayQueryHelper($strOrderBy, $strLimit, $strLimitPrefix, $strLimitSuffix, $strExpandSelect, $strExpandFrom, $objExpansionMap, $objDatabase);

           // Properly Escape All Input Parameters using Database->SqlVariable()
           //$strSuche = utf8_decode($objDatabase->SqlVariable($strSuche));
           $strSuche = $objDatabase->SqlVariable($strSuche);

           $strSuche = str_replace(“'”, '', $strSuche);



           // Setup the SQL Query
           $strQuery = sprintf('
               SELECT
               %s
                   `funktion`.`Funktion_Id` AS `Funktion_Id`,
                   `funktion`.`Titel` AS `Titel`,
                   `funktion`.`Name` AS `Name`,
                   `funktion`.`Vorname` AS `Vorname`,
                   `funktion`.`Beschreibung` AS `Beschreibung`,
                   `funktion`.`TelefonNr` AS `TelefonNr`,
                   `funktion`.`Raum` AS `Raum`,
                   `funktion`.`Orga_Id` AS `Orga_Id`,
                   `funktion`.`Pos` AS `Pos`,
                   `funktion`.`io_NST` AS `io_NST`,
                   `funktion`.`io_Anschluss` AS `io_Anschluss`,
                   `funktion`.`io_Benutzer` AS `io_Benutzer`,
                   `funktion`.`EMail` AS `EMail`,
                   `funktion`.`Fax` AS `Fax`,
                   `funktion`.`Mobil` AS `Mobil`
                   %s
               FROM
                   `funktion` AS `funktion`
                   %s
               WHERE Name LIKE %s OR Vorname LIKE %s

               %s
               %s', $strLimitPrefix, $strExpandSelect, $strExpandFrom,
               “'%$strSuche%'”, “'%$strSuche%'”, $strOrderBy, $strLimitSuffix);

           // Perform the Query and Instantiate the Result

           //echo “query: $strQuery<br />”;

           $objDbResult = $objDatabase->Query($strQuery);
           QApplication::$Database[1]->OutputProfiling();
           return Funktion::InstantiateDbResult($objDbResult);

}

All fields, excepts the with the underscore are retrieved properly, the fiels with the underscore are null.

How can I solve this problem? Or, is possible to rewrite it to QQN-Notation?

thank in advance

flunki

#2  |  flunki (Rathlau, Germany) Germany
Monday, January 11, 2010, 6:43 AM PST

Hi Forum,

solved it:

public static function LoadArrayBySample($strParam, $objOptionalClauses = null) {
           // This will return an array of Funktion objects
           return Funktion::QueryArray(
               QQ::OrCondition(
                   QQ::Like(QQN::Funktion()->Name, '%'.$strParam.'%'),
                   QQ::Like(QQN::Funktion()->Vorname, '%'.$strParam.'%')
               ),
               $objOptionalClauses
           );
       }

mfg

flunki



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.