Exemple #1
0
 public function autoErrorReport()
 {
     if (defined('DEV') && DEV == true && $this->success == FALSE && $this->query !== NULL) {
         if (!class_exists('Debug')) {
             include_once "library/facil3/utils/Debug.class.php";
         }
         Debug::print_r($this);
     }
 }
Exemple #2
0
 private function newConnection($id)
 {
     $connectionData = Model::getConnectionsData();
     // Run::$DEBUG_PRINT = 1;
     if (!$id) {
         foreach ($connectionData as $k => $v) {
             if ($v['type_db'] == "postgre") {
                 $id = $k;
                 break;
             }
         }
     }
     if (isset($connectionData[$id])) {
         Debug::log("Iniciando POSTGRE.", __LINE__, __FUNCTION__, __CLASS__, __FILE__);
         $data = $connectionData[$id];
         Debug::print_r("data", $data);
         if (self::$active == false) {
             self::$active = $id;
         }
         $host = $data["host"];
         $name = $data["database"];
         $user = $data["user"];
         $pass = $data["pass"];
         $this->schema = $data["schema"];
         if ($host && $name && $user) {
             try {
                 self::$connection[$id] = pg_connect('host=' . $host . ' dbname=' . $name . ' user='******' password='******'');
                 return -2;
             }
             if (self::$connection[$id]->connect_error) {
                 ob_flush();
                 flush();
                 Error::show(5200, "Erro ao conectar ao POSTGRE. Código:" . Run::$control->string->encoding(pg_last_error(self::$connection[$id]) . ' -- Mensagem:' . pg_last_error(self::$connection[$id])), __FILE__, __LINE__, '');
                 return -2;
             }
         } else {
             Error::show(5200, "Não conecta no POSTGRE: " . $host . " / " . $name . " / " . $user . " / ", __FILE__, __LINE__, '');
             return -2;
         }
     } else {
         Error::show(0, "Dados de conexão <b>{$id}</b> não foram definidos ", __FILE__, __LINE__, '');
         exit;
     }
 }
Exemple #3
0
 private function newConnection($id)
 {
     $connectionData = Model::getConnectionsData();
     if (!$id) {
         foreach ($connectionData as $k => $v) {
             if ($v['type_db'] == "mysql") {
                 $id = $k;
                 break;
             }
         }
     }
     //Run::$DEBUG_PRINT = 1;
     //Debug::print_r("__construct", $id);
     if (isset($connectionData[$id])) {
         $data = $connectionData[$id];
         //Debug::print_r("data ", $data);
         Debug::log("Iniciando Mysqli.", __LINE__, __FUNCTION__, __CLASS__, __FILE__);
         self::$active = $id;
         $host = $data["host"];
         $name = $data["database"];
         $user = $data["user"];
         $pass = $data["pass"];
         $this->schema = $data["schema"];
         if ($host && $name && $user) {
             //echo "$host, $user, $pass, $name";
             self::$connection[$id] = new mysqli($host, $user, $pass, $name);
             self::$connection[$id]->set_charset("utf8");
             Debug::print_r("conectando mysql {$id} ");
             if (self::$connection[$id]->connect_error) {
                 ob_flush();
                 flush();
                 Error::show(5200, "Erro ao conectar ao Mysqli (<b>{$id}</b>). Código:" . Run::$control->string->encoding(self::$connection[$id]->connect_errno . ' -- Mensagem:' . self::$connection[$conn]->connect_error), __FILE__, __LINE__, '');
                 return -2;
             } else {
                 self::$connection[$id]->set_charset("utf8");
             }
         } else {
             Error::show(5200, "Não conecta no MYSQLI (<b>{$id}</b>): " . $host . " / " . $name . " / " . $user . " / ", __FILE__, __LINE__, '');
             return -2;
         }
     } else {
         Error::show(0, "Dados de conexão <b>{$id}</b> não foram definidos ", __FILE__, __LINE__, '');
         exit;
     }
 }
Exemple #4
0
 public function delDataSession()
 {
     // método para deletar o dataForm na sessão
     Debug::print_r("delDataSession");
     Run::$session->del(array("forms", $this->getFormSessionId()));
 }
Exemple #5
0
 public function dev__teste__teste2()
 {
     echo "<br clear='all' /><br clear='all' /> <br clear='all' /> teste 2 <br clear='all' /> ";
     Debug::print_r(Language::$phrases);
 }
Exemple #6
0
 public function init()
 {
     $returnResult = new HttpResult();
     $returnResult->setSuccess(1);
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new HttpMenu();
     //inicia a variavel de consulta de obj para cache
     $obj = NULL;
     $save_cache = TRUE;
     $cache_base_folder = "cache/menu/init/";
     if (Config::USE_QUERY_CACHE) {
         //verifica se tem cache
         $cache_folder = $cache_base_folder;
         $cache_file = md5(implode("/", $this->arrayRestFolder));
         /*
         Debug::print_r($this->arrayRestFolder);
         echo Debug::li($cache_file);
         */
         $cache_location = $cache_folder . $cache_file;
         if (file_exists($cache_location)) {
             $resultSerial = unserialize(file_get_contents($cache_location));
             //return $resultSerial;
             $obj = $resultSerial;
             $save_cache = FALSE;
         }
     }
     //o cache não está gravado
     if ($obj == NULL) {
         $obj = $this;
         //pedindo para consultar
         $this->consultValues();
     }
     $retornoDaPaginaHTML->arrayMaterial = $obj->arrayMaterial->result;
     $retornoDaPaginaHTML->arrayColor = $obj->arrayColor->result;
     $retornoDaPaginaHTML->arrayStyle = $obj->arrayStyle->result;
     $retornoDaPaginaHTML->arrayFormat = $obj->arrayFormat->result;
     $retornoDaPaginaHTML->arrayTheme = $obj->arrayTheme->result;
     $retornoDaPaginaHTML->arrayComposition = $obj->arrayComposition->result;
     $retornoDaPaginaHTML->arrayTechnique = $obj->arrayTechnique->result;
     $retornoDaPaginaHTML->arrayType = $obj->arrayType->result;
     $botaoPromocoes = new stdClass();
     $botaoPromocoes->name = "em promoção";
     //echo Debug::li($this->currentQuery);exit();
     if (!$this->currentQuery) {
         $this->currentQuery = "SELECT count( DISTINCT `view_product_model_quadro_b`.id) as count FROM `view_product_model_quadro_b` WHERE 1 AND view_product_model_quadro_b.`active` = '1'";
     }
     $queryPromocao = $this->currentQuery . " AND promocao = 1 ";
     //oic 2
     $dbi = new DbInterface();
     $rt = $dbi->query($queryPromocao);
     //echo Debug::li($this->currentQuery);
     if (isset($_GET["teste"])) {
         Debug::print_r($rt);
     }
     $rt->fetchAll();
     //Debug::print_r($rt);exit();
     $botaoPromocoes->id = 1;
     $botaoPromocoes->total = $rt->result[0]->count;
     //total de produtos em promoção
     $retornoDaPaginaHTML->arrayPromocoes = array($botaoPromocoes);
     $retornoDaPaginaHTML->requestMaterial = $obj->requestMaterial;
     $retornoDaPaginaHTML->requestColor = $obj->requestColor;
     $retornoDaPaginaHTML->requestStyle = $obj->requestStyle;
     $retornoDaPaginaHTML->requestFormat = $obj->requestFormat;
     $retornoDaPaginaHTML->requestTheme = $obj->requestTheme;
     $retornoDaPaginaHTML->requestComposition = $obj->requestComposition;
     $retornoDaPaginaHTML->requestTechnique = $obj->requestTechnique;
     $retornoDaPaginaHTML->requestType = $obj->requestType;
     $retornoDaPaginaHTML->requestSearch = $obj->requestSearch;
     $retornoDaPaginaHTML->requestResumeSearch = $obj->requestResumeSearch;
     $retornoDaPaginaHTML->requestPromocao = $obj->requestPromocao;
     $retornoDaPaginaHTML->arrayRestFolder = $this->arrayRestFolder;
     $retornoDaPaginaHTML->arrayVariable = $this->arrayVariable;
     $retornoDaPaginaHTML->url_final = $obj->url_final;
     //salvando o objeto de resultado de html no retorno
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     // -------------------------------------------------------------------[ BREAD CRUMB ]
     // Agora criando a array de bread crumb
     $retornoDaPaginaHTML->arrayBreadCrumb = $this->arrayBreadCrumb;
     // E também popula os títulos, que até então ele não tinha como pegar
     foreach ($retornoDaPaginaHTML->arrayBreadCrumb as $BreadCrumbInfoVO) {
         //pelo tipo de item e id ele ve o nome
         if (FALSE) {
             //apenas para o auto completar do eclipse
             $BreadCrumbInfoVO = new BreadCrumbInfoVO();
         }
         $BreadCrumbInfoVO->tittle = $retornoDaPaginaHTML->getNameByTypeAndId($BreadCrumbInfoVO->reference, $BreadCrumbInfoVO->id);
     }
     if (Config::USE_QUERY_CACHE && $save_cache) {
         //grava o cache
         DataHandler::createRecursiveFoldersIfNotExists($cache_folder);
         //criando obj simplificado para serializar
         $stdObj = new stdClass();
         $stdObj->arrayMaterial = $obj->arrayMaterial;
         $stdObj->arrayColor = $obj->arrayColor;
         $stdObj->arrayStyle = $obj->arrayStyle;
         $stdObj->arrayFormat = $obj->arrayFormat;
         $stdObj->arrayTheme = $obj->arrayTheme;
         $stdObj->arrayComposition = $obj->arrayComposition;
         $stdObj->arrayTechnique = $obj->arrayTechnique;
         $stdObj->arrayType = $obj->arrayType;
         $stdObj->requestMaterial = $obj->requestMaterial;
         $stdObj->requestColor = $obj->requestColor;
         $stdObj->requestStyle = $obj->requestStyle;
         $stdObj->requestFormat = $obj->requestFormat;
         $stdObj->requestTheme = $obj->requestTheme;
         $stdObj->requestComposition = $obj->requestComposition;
         $stdObj->requestTechnique = $obj->requestTechnique;
         $stdObj->requestType = $obj->requestType;
         $stdObj->requestSearch = $obj->requestSearch;
         $stdObj->requestResumeSearch = $obj->requestResumeSearch;
         $stdObj->requestPromocao = $obj->requestPromocao;
         $stdObj->url_final = $obj->url_final;
         DataHandler::writeFile($cache_folder, $cache_file, serialize($stdObj));
     }
     return $returnResult;
 }
Exemple #7
0
					<li style="margin-left:60px;"><a href="<?php 
echo Config::getRootPath('produtos');
?>
">Produtos</a></li>
					<li><a href="<?php 
echo Config::getRootPath('clientes');
?>
">clientes</a></li>
				</ul>
				<div id="line"></div>
			</div>
			<div id="products">
				<?php 
foreach ($HttpContentResult->produtos as $produto) {
    ?>
				<div class="products" id="products-<?php 
    echo $i;
    ?>
">
					<?php 
    Debug::print_r($produto);
    ?>
				</div>
				<?php 
}
?>
	
			</div>
	<div>
</body>
</html>
Exemple #8
0
 /**
  * para detalhe de um produto
  */
 public function init()
 {
     //Debug::print_r($this->arrayVariable);
     //filtro vindo por parametro é o addres que ele tem que enviar de volta como busca
     //rel ids de produtos relacionados
     //exit();
     //echo 12;
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     if ($id > 0) {
         $ContentSiteVO = new ContentSiteVO();
         $ReturnResult_vo = $ContentSiteVO->setId($id, TRUE);
         if ($ReturnResult_vo->success) {
             $stdProduct = $ContentSiteVO->toStdClass();
             $stdProduct->array_gallery = $ContentSiteVO->getImages(NULL, "gallery", true);
             $stdProduct->array_dimensions = $ContentSiteVO->getImages(NULL, "dimensions", true);
             $stdProduct->array_video = $ContentSiteVO->getImages(NULL, "video", true);
             $stdProduct->array_360 = $ContentSiteVO->getImages(NULL, "360", true);
             $stdProduct->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", true);
             $LinkDAO = LinkDAO::getInstance();
             //passo 1, descobrir a qual família esse protudo pertence
             //passo 2, pegar todos os produtos pertencente a mesma família
             //passo 3, tirar o próprio produto da listagem de produtos da mesma família
             $array_links = array();
             $resultLinks = $LinkDAO->select(DbInterface::RETURN_STD_OBJECT, "content", $table_id = null, $linked_table = 'content', $linked_table_id = $id, $active = 1, $quant_started = NULL, $quant_limit = NULL, $order_by = "order", $order_type = " ASC ");
             if ($resultLinks->success && $resultLinks->count_total > 0) {
                 foreach ($resultLinks->result as $familia) {
                     $link = $familia;
                     //$resultLinks->result[0];
                     $ContentFamiliaVO = new ContentSiteVO();
                     $ContentFamiliaVO->setId($link->table_id, TRUE);
                     Debug::print_r($ContentFamiliaVO);
                     exit;
                     if ($ContentFamiliaVO->active > 0) {
                         $arrayResult_links = $ContentFamiliaVO->getLinks("content");
                         foreach ($arrayResult_links as $link) {
                             if ($link->linked_table_id != $id) {
                                 $ResultTempLink = $link->getLinkedVO();
                                 if ($ResultTempLink->success) {
                                     $produtoVO = $ResultTempLink->result;
                                     if ($produtoVO->active > 0) {
                                         $stdProduto = $produtoVO->toStdClass();
                                         $stdProduto->array_tagged = $produtoVO->getImages(NULL, "tagged", NULL);
                                         $array_links[] = $stdProduto;
                                     }
                                     //Debug::print_r($stdProduto);exit();
                                 }
                             }
                             //end if
                         }
                         //end foerach
                     }
                 }
             }
             //verifica a qual familia esse produto pertence
             $stdProduct->array_produtos_vinculados = $array_links;
             //Debug::print_r($array_links);
             //exit();
             //pegando array de vinculados enviados como id
             $str_ids_send = DataHandler::getValueByArrayIndex($this->arrayVariable, "rel");
             $array_ids_send = explode("|", $str_ids_send);
             $array_filtro = array();
             foreach ($array_ids_send as $id) {
                 $ContentSiteVO = new ContentSiteVO();
                 $tempResult = $ContentSiteVO->setId($id, TRUE);
                 if ($tempResult->success) {
                     $stdProduto = $ContentSiteVO->toStdClass();
                     $stdProduto->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", NULL);
                     $array_filtro[] = $stdProduto;
                 }
             }
             $stdProduct->array_filtro = $array_filtro;
             //Debug::print_r($array_links);
             $returnResult = new HttpResult();
             //exit();
             //iniciando o resultado para o html
             $retornoDaPaginaHTML = new HttpRoot();
             $retornoDaPaginaHTML->vo = $stdProduct;
             $retornoDaPaginaHTML->addressToReturn = str_replace("|", "/", DataHandler::getValueByArrayIndex($this->arrayVariable, "filtro"));
             $strToResend = implode("/", $this->arrayRestFolder);
             $strToResend = explode("/:/", $strToResend);
             if (is_array($strToResend) && count($strToResend) > 1) {
                 $strToResend = $strToResend[1];
             } else {
                 $strToResend = "";
             }
             $retornoDaPaginaHTML->addressToResend = $strToResend;
             $returnResult->setHttpContentResult($retornoDaPaginaHTML);
             return $returnResult;
         } else {
             Navigation::redirect("");
         }
     } else {
         //não mandou o id, vai pra listagem
         Navigation::redirect("produtos");
     }
 }
Exemple #9
0
 private function buildSaveSQL($orderTables, $dataTables, $schema, $refTableIndex = false, $refPkId = 0)
 {
     //Run::$DEBUG_PRINT = 1;
     $fieldsRec = array();
     //Debug::print_r($orderTables);
     foreach ($orderTables as $k => $refs) {
         if (!isset($refs['table'])) {
             continue;
         }
         $this->deletePKFromMultipleRegistersTable($refs, $k, $schema);
         $data = $dataTables[$k];
         $tableIsMultiple = false;
         if (isset($refs['multiple']) && $refs['multiple'] === true) {
             //$dataCheck			= (is_array($data[$refTableIndex])) ? $data[$refTableIndex] : $data;
             //$totalMultiple 		= $this->getTotalMultipleFieldsBytable($k, $dataCheck, $schema, $refs['pk'], $refTableIndex);
             $dataLevel = $this->getLevelDataMulti($data);
             $dataIndexs = $this->getIndexsMultipleFieldsByTable($k, $data, $schema, $refs['pk'], $refTableIndex, $refPkId, $dataLevel);
             $totalMultiple = count($dataIndexs);
             //Debug::print_r("dataIndexs Array:: ",$dataIndexs);
             $tableIsMultiple = true;
         } else {
             $totalMultiple = 1;
         }
         Debug::print_r("buildSaveSQL {$k} | refTableIndex : {$refTableIndex} | refPkId : {$refPkId} - - - - - - - - - - SAVE {$refs['table']}: {$k}  / multiplos: " . $totalMultiple . " - - refTableIndex: {$refTableIndex}- - - - - - - - - - - - - - - - -");
         //reset($data);
         for ($i = 0; $i < $totalMultiple; $i++) {
             $reIndexed = $dataIndexs[$i];
             $fields = "";
             $values = "";
             $update_fields = "";
             if (!$tableIsMultiple) {
                 $dataPK = $data[$refs['pk']];
             } else {
                 if ($dataLevel == 2) {
                     $dataPK = $data[$reIndexed][$refs['pk']];
                 } else {
                     if ($dataLevel == 3) {
                         $dataPK = $data[$refTableIndex][$reIndexed][$refs['pk']];
                     }
                 }
             }
             //Debug::print_r(" data:", $data);
             //Debug::print_r("dataPK $k : ".$dataPK ." // dataLevel:".$dataLevel);
             $typeSave = $dataPK > 0 ? "update" : "insert";
             $saveFileData = array("index" => false, "name" => false, "fieldRef" => false, "path" => false);
             //Debug::print_r("for $i / dataPK: $dataPK ");
             //Debug::print_r($data[$i]);
             // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
             if (isset($refs['fk_ref'])) {
                 $fields .= ",\n\t" . $refs['fk_ref'] . "";
                 $values .= ",\n\t'" . $orderTables['fk_ref_value'] . "'";
                 $update_fields .= ",\n\t" . $refs['fk_ref'] . " = '" . $orderTables['fk_ref_value'] . "'";
             }
             // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
             $skipRec = false;
             foreach ($schema['fields'] as $kF => $field) {
                 if ($field['belongsTo'] == $k && ($dataPK > 0 && $kF == $refs['pk'] || $kF != $refs['pk'])) {
                     if ($typeSave == "insert" && $field[$typeSave] !== false || $typeSave == "update" && $field[$typeSave] !== false) {
                         if ($tableIsMultiple) {
                             //if($k == "et")	//Debug::print_r($data[$refTableIndex][$i]);
                             //if($k == "et")	//Debug::print_r("$k /kF $kF /i $i =".$data[$refTableIndex][$i][$kF]);
                             if ($field['type'] == "date_insert" || $field['type'] == "date_update") {
                                 $data_multiple = $data[$kF];
                             } else {
                                 if ($field['type'] == "int" || $field['type'] == "integer") {
                                     $data_multiple = is_array($data[$refTableIndex][$reIndexed]) ? $data[$refTableIndex][$reIndexed][$kF] : (int) $data[$reIndexed][$kF];
                                 } else {
                                     $data_multiple = is_array($data[$refTableIndex][$reIndexed]) ? $data[$refTableIndex][$reIndexed][$kF] : $data[$reIndexed][$kF];
                                     //Debug::p("data ", $data);
                                     //Debug::p("data_multiple  / $reIndexed / $kF /".$data[$reIndexed][$kF], $data);
                                     //Debug::p("data_multiple ", $data[$reIndexed][$kF]);
                                 }
                             }
                             if ($field['skipRecEmpty'] === true && $this->getValueArray($data_multiple) == "") {
                                 continue 2;
                             }
                             if ($field['skipFieldEmpty'] === true && $this->getValueArray($data_multiple) == "") {
                                 continue;
                             }
                             $field_name = $field['name'] != "" ? $field['name'] : $kF;
                             $fields .= ",\n\t" . $field_name . "";
                             $values .= ",\n\t'" . $this->getValueArray($data_multiple) . "'";
                             $update_fields .= ",\n\t" . $field_name . " = '" . $this->getValueArray($data_multiple) . "'";
                             if ($field['type'] == "file_name") {
                                 $saveFileData['name'] = $this->getValueArray($data_multiple);
                             }
                             if ($field['type'] == "file_path") {
                                 $saveFileData['index'] = $reIndexed;
                                 $saveFileData['fieldRef'] = $field['fieldRef'];
                                 $saveFileData['path'] = $this->getValueArray($data_multiple);
                                 //Debug::p("saveFileData", $saveFileData);
                             }
                             if ($field['type'] == "file_path" && $saveFileData['path'] == $saveFileData['name'] && !is_array($data_multiple)) {
                                 continue 2;
                             }
                             //Debug::p("add: ($reIndexed)".$field_name ." / PK: ". $dataPK ." /kF = ". $kF ." /Total = ". $totalMultiple ." /reIndexed = ".$reIndexed);
                             //if($kF == "tipo") //Debug::p("$i $kF :".$data_multiple);
                             //if($kF == "tipo") //Debug::p($data[$refTableIndex][$i][$kF]);
                         } else {
                             if ($field['type'] == "file_name") {
                                 $saveFileData['name'] = $data[$kF];
                             }
                             if ($field['type'] == "file_path") {
                                 $saveFileData['index'] = $reIndexed;
                                 $saveFileData['fieldRef'] = $field['fieldRef'];
                                 $saveFileData['path'] = $data[$kF];
                                 //Debug::p("saveFileData", $saveFileData);
                             }
                             if ($field['type'] == "file_path" && $saveFileData['path'] == $saveFileData['name'] && !is_array($data_multiple)) {
                                 continue 2;
                             }
                             if ($field['skipRecEmpty'] === true && $data[$kF] == "") {
                                 continue 2;
                             }
                             if ($field['skipFieldEmpty'] === true && $data[$kF] == "") {
                                 continue;
                             }
                             $field_name = $field['name'] != "" ? $field['name'] : $kF;
                             $fields .= ",\n\t" . $field_name . "";
                             if ($field['type'] == "int" || $field['type'] == "integer") {
                                 $data[$kF] = (int) $data[$kF];
                             }
                             $values .= ",\n\t'" . $data[$kF] . "'";
                             if ($field['skipFieldEmpty'] !== true || $field['skipFieldEmpty'] === true && $data[$kF] != $field['value']) {
                                 $update_fields .= ",\n\t" . $field_name . " = '" . $data[$kF] . "'";
                             }
                         }
                     }
                 }
             }
             // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
             $fields = substr($fields, 2, strlen($fields));
             $values = substr($values, 2, strlen($values));
             $update_fields = substr($update_fields, 2, strlen($update_fields));
             //Run::$DEBUG_PRINT = 1;
             Debug::p("data", $data);
             Debug::p("update_fields", $update_fields);
             if ($dataPK > 0) {
                 // não pode ser com replace, pois os campos não atualizados são apagados do registro.
                 //$sql_query = "REPLACE INTO ". $refs['table'] ." \n(\n".$fields ."\n) \nVALUES(\n".$values."\n)";
                 $sql_query = "UPDATE " . $this->database->schema . $refs['table'] . " SET \n" . $update_fields . "\n \n WHERE \n\t {$refs['pk']} = {$dataPK} \n";
             } else {
                 $sql_query = "INSERT INTO " . $this->database->schema . $refs['table'] . " \n(\n" . $fields . "\n) \nVALUES(\n" . $values . "\n)";
             }
             Debug::p("sql_query", $sql_query);
             if ($saveFileData['name'] === "" && $saveFileData['path'] !== false) {
                 continue;
             }
             //	//Debug::p("pqp ------------{$saveFileData['name']}------------------------- {$saveFileData['path']} ");
             $sql_obj = $this->database->query($sql_query, $refs['pk'], __LINE__, __FUNCTION__, __CLASS__, __FILE__, $this->settings['database_id']);
             $warMsg = $this->database->getWarning();
             if ((is_integer($sql_obj) || $warMsg != "") && $this->database->getError() != "00000") {
                 $this->query_errors++;
                 Error::show(5200, "Model-> Erro no SQL:\n " . $warMsg . "\n  " . $this->database->getError() . "  \n{$sql_query} " . __FUNCTION__, __FILE__, __LINE__, '');
             } else {
                 //Debug::log("Model: SQL Executado com sucesso (returnID:". $this->database->getID($this->settings['database_id']) ."): \n $sql_query", __LINE__, __FUNCTION__, __CLASS__, __FILE__);
             }
             if ($dataPK > 0) {
                 $id_pf_ref = $data[$refs['pk']] = $dataPK;
             } else {
                 $id_pf_ref = $this->database->getID($sql_query);
             }
             if (isset($dataTables[$k][$refTableIndex][$reIndexed][$refs['pk']])) {
                 $dataTables[$k][$refTableIndex][$reIndexed][$refs['pk']] = $id_pf_ref;
             } else {
                 if ($tableIsMultiple) {
                     $dataTables[$k][$reIndexed][$refs['pk']] = $id_pf_ref;
                 } else {
                     $dataTables[$k][$refs['pk']] = $id_pf_ref;
                 }
             }
             //Debug::print_r("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ".$refs['pk'] ." = " . $id_pf_ref ." -- totalMultiple: ".$totalMultiple);
             //Debug::print_r($sql_query);
             if ($this->query_errors < 1) {
                 Debug::p("TESTE", $saveFileData);
                 $refs["joineds"]['fk_ref_value'] = $id_pf_ref;
                 if ($reIndexed == "") {
                     $reIndexed = (int) $reIndexed;
                 }
                 Debug::p("TESTE2", $saveFileData);
                 Debug::p("TESTE3", $saveFileData);
                 Debug::p("FILE SAVE:", $_FILES[$saveFileData['fieldRef']]['tmp_name']);
                 if ($saveFileData['path'] !== false && $saveFileData['name'] !== false && $saveFileData['name'] !== "" && $saveFileData['index'] !== false && (isset($_FILES[$saveFileData['fieldRef']][$refTableIndex][$saveFileData['index']]['tmp_name']) || isset($_FILES[$saveFileData['fieldRef']][$saveFileData['index']]['tmp_name'])) || isset($_FILES[$saveFileData['fieldRef']]['tmp_name']) && !is_array($_FILES[$saveFileData['fieldRef']]['tmp_name']) && $_FILES[$saveFileData['fieldRef']]['tmp_name'] != "") {
                     Debug::p("vai salvar", $id_pf_ref);
                     $tmp_file = !is_string($_FILES[$saveFileData['fieldRef']][(int) $refTableIndex]['tmp_name']) ? $_FILES[$saveFileData['fieldRef']][$refTableIndex][$saveFileData['index']]['tmp_name'] : $_FILES[$saveFileData['fieldRef']][$saveFileData['index']]['tmp_name'];
                     if ($saveFileData['index'] == "") {
                         $tmp_file = $_FILES[$saveFileData['fieldRef']]['tmp_name'];
                     }
                     Debug::p("tmp_file", $tmp_file);
                     if ((int) $refPkId == 0) {
                         $refPkId = $id_pf_ref;
                     }
                     $salvou = false;
                     if ($tmp_file != "") {
                         $salvou = Run::$control->file->saveFile($tmp_file, Run::$control->string->pad($id_pf_ref, $this->settings['default_pad'], "0", STR_PAD_LEFT) . "-" . $saveFileData['name'], $saveFileData['path'] . $refPkId, "");
                         Debug::p("FILE SAVE CHECK ", $salvou);
                         if ($salvou === false) {
                             array_push($this->dataErrors, "O arquivo " . $saveFileData['name'] . " não pode ser salvo.");
                         }
                     }
                 }
                 $dataTables = $this->buildSaveSQL($refs["joineds"], $dataTables, $schema, $reIndexed, $id_pf_ref);
             } else {
                 array_push($this->dataErrors, "Ocorreu um erro ao gravar os dados da tabela " . $refs['table'] . ".");
             }
         }
     }
     //Run::$DEBUG_PRINT = 0;
     //exit;
     return $dataTables;
 }
Exemple #10
0
 public function register()
 {
     Debug::print_r($_POST);
     exit;
 }