Beispiel #1
0
 /**
  * Get all records by execute SQL suggest
  *
  * @param string $processUid    Unique id of Process
  * @param string $variableName  Variable name
  * @param array  $arrayVariable The variables
  *
  * return array Return an array with all records
  */
 public function executeSqlSuggest($processUid, $variableName, array $arrayVariable = array())
 {
     try {
         $arrayRecord = array();
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfNotExistsProcess($processUid, strtolower("PRJ_UID"));
         //Set data
         \G::LoadClass('pmDynaform');
         $pmDynaform = new \pmDynaform();
         $field = $pmDynaform->searchField($arrayVariable["dyn_uid"], $variableName);
         $variableDbConnectionUid = $field !== null ? $field->dbConnection : "";
         $variableSql = $field !== null ? $field->sql : "";
         //Get data
         $_SESSION["PROCESS"] = $processUid;
         $cnn = \Propel::getConnection($variableDbConnectionUid . "" != "" ? $variableDbConnectionUid : "workflow");
         $stmt = $cnn->createStatement();
         $replaceFields = G::replaceDataField($variableSql, $arrayVariable);
         $filter = "";
         if (isset($arrayVariable["filter"])) {
             $filter = $arrayVariable["filter"];
         }
         $start = 0;
         if (isset($arrayVariable["start"])) {
             $start = $arrayVariable["start"];
         }
         $limit = "";
         if (isset($arrayVariable["limit"])) {
             $limit = $arrayVariable["limit"];
         }
         $parser = new \PHPSQLParser($replaceFields);
         $filter = str_replace("'", "''", $filter);
         $replaceFields = $this->queryModified($parser->parsed, $filter, "*searchtype*", $start, $limit);
         $rs = $stmt->executeQuery($replaceFields, \ResultSet::FETCHMODE_NUM);
         while ($rs->next()) {
             $row = $rs->getRow();
             $arrayRecord[] = array(strtolower("VALUE") => $row[0], strtolower("TEXT") => isset($row[1]) ? $row[1] : $row[0]);
         }
         //Return
         return $arrayRecord;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Beispiel #2
0
    /**
     * Get all records by execute SQL
     *
     * @param string $processUid    Unique id of Process
     * @param string $variableName  Variable name
     * @param array  $arrayVariable The variables
     *
     * return array Return an array with all records
     */
    public function executeSql($processUid, $variableName, array $arrayVariable = array())
    {
        try {
            $arrayRecord = array();

            //Verify data
            $process = new \ProcessMaker\BusinessModel\Process();

            $process->throwExceptionIfNotExistsProcess($processUid, strtolower("PRJ_UID"));

            //Set data
            \G::LoadClass('pmDynaform');
            $pmDynaform = new \pmDynaform();
            $field = $pmDynaform->searchField($arrayVariable["dyn_uid"], $arrayVariable["field_id"]);
            $variableDbConnectionUid = $field !== null ? $field->dbConnection : "";
            $variableSql = $field !== null ? $field->sql : "";

            //Get data
            $_SESSION["PROCESS"] = $processUid;

            $cnn = \Propel::getConnection(($variableDbConnectionUid . "" != "")? $variableDbConnectionUid : "workflow");
            $stmt = $cnn->createStatement();

            $replaceFields = G::replaceDataField($variableSql, $arrayVariable);

            $rs = $stmt->executeQuery($replaceFields, \ResultSet::FETCHMODE_NUM);

            while ($rs->next()) {
                $row = $rs->getRow();

                $arrayRecord[] = array(
                    strtolower("VALUE") => $row[0],
                    strtolower("TEXT") => isset($row[1]) ? $row[1] : $row[0]
                );
            }

            //Return
            return $arrayRecord;
        } catch (\Exception $e) {
            throw $e;
        }
    }