Posts by DNick • 2,862 points
107 posts
-
11
votes1
answer237
viewsQ: What are the architectural database options for Microservices?
Recently I met the architectural pattern called SAGA or Business Transactions. And researching I found this question also speaking of the SAGA pattern. There are other patterns besides SAGA?…
-
6
votes1
answer668
viewsA: Can I accept a pull request locally? Via terminal or Github desktop?
First let’s define what use is the pull request Pull requests allow you to inform other people about the changes you have made push for a branch into a repository on Github. After a pull request is…
-
2
votes0
answers41
viewsQ: Is the load and processing dynamics between HTML and CSS asynchronous?
After the Three-way Handshake, that is, establishing the TCP connection between the client and the server. The client starts downloading the files. My doubts are: If in an HTML page that contains…
-
3
votes1
answer2683
viewsQ: Use status code 422 for Invalidargumentexception type exceptions
According to the PHP documentation the exception InvalidArgumentException should be used when an argument not expected by the application is received. Second status code 400 and 422 on the website…
-
8
votes2
answers537
viewsA: How to recover only one specific stash file?
you can apply the use of git checkout or git show to restore a specific file. git checkout stash@{0} -- <nome do arquivo> To list the files: git stash list // stash@{0}: nome da branch que foi…
-
0
votes2
answers35
viewsQ: Why is the return 115?
The question is quite explanatory. Because the return in the last %s is 115? $key = 0; $count = 33; $id = 1; echo printf("%s de %s - ID: %s", ++$key, $count, $id); // 1 de 33 - ID: 115…
-
1
votes0
answers25
viewsQ: Javascript Behavior Driven Design (Behavior Driven) Language Testing
In languages such as PHP and Java, for example, tests follow the concept of unit testing. In the Javascript world they say the approach is a little different and terminology is being disseminated…
-
0
votes5
answers2538
viewsA: How to use Try Catch on an Insert
In my opinion the best way to use a block of exception related to the database is using PDO::beginTransaction. Take a look at the item Applying business rules when an exception occurs of reply: What…
-
6
votes5
answers31170
viewsA: What are Try/Catch Blocks for and when should they be used?
The best way to understand the importance of using blocks try{} catch{} finally{} is to have total science of a truth in the world of programming: There is no application that does not generate…
-
0
votes1
answer37
viewsA: How to configure phpunit with Scrutinizer?
Come on, we will use as a starting point that your machine has the version php7.2 with the xdebug installed and configured. Typing command php -v the terminal output will be similar to this: PHP…
-
0
votes1
answer37
viewsQ: How to configure phpunit with Scrutinizer?
Following the document of Scrutinizer I realized the creation of the archive .scrutinizer.yml in the project in PHP. Analyzing other sites got to the final result of the file demonstrated below:…
-
1
votes1
answer104
viewsQ: How to answer a json using Gson
First of all, I agree that the question has gotten a little strange, but I can’t write my question otherwise. At the end of the explanation of the problem if someone wants to suggest a better title…
-
7
votes1
answer282
viewsQ: Hashmap sorting by value and assigning to a dto using java 8
I currently have the following scenario functional: A list of the Studios class with id and name: List<Studios> studios; I count the names repeated on List thus: Map<String, Integer>…
-
0
votes2
answers2457
viewsA: How to use the controller in a java application
When you’re talking about Controller. I believe you’re talking about architecture MVC (Model-View-Controller). When we use the standard MVC terms as a goal to separate the application into 3 layers.…
-
0
votes1
answer62
viewsA: How to return a data collection using Doctrine Resultsetmapping?
For your case, you can use addScalarResult to map each column of the script return. It’s very simple. I recently answered a question that might help you, right here. In your case it would look like…
-
0
votes1
answer60
viewsA: Bring multiple values from a Join in mysql
Following example: CREATE TEMPORARY TABLE produtos_temp ( id int, descricao varchar(100) ); INSERT INTO produtos_temp VALUES( 1, "Camisa Tal" ); INSERT INTO produtos_temp VALUES( 2, "Bermuda Tal" );…
-
0
votes1
answer31
viewsQ: How to structure the parameters in a javascript object
I have the following code: var colHeaders = [ "Column 1", "Column 2" ]; var columns = [ {data: 'column_1', validator: validatorRentalCode, allowEmpty: false, allowInvalid: false}, {data: 'column_2',…
-
0
votes2
answers115
viewsA: Search information in the database with validation of Hibernate parameters
To show how I used the example above. If anyone needs: session.beginTransaction(); Query query = session.createSQLQuery(sql); map.forEach(query::setParameter); List result =…
-
3
votes2
answers115
viewsQ: Search information in the database with validation of Hibernate parameters
Analyze the following situation: will come in request the information of the country that can be {0, 1, 2}. The replacement method will look like this: Nomenclature of the country parameter: 0:…
-
0
votes1
answer499
viewsA: How to read . sql file with Java
String sqlString = path_to_file; String sql = IOUtils.toString(new FileInputStream(sqlString), "UTF-8"); getSession().createSQLQuery(sql); I took it and applied it Tranformers hibernate to process…
-
0
votes1
answer499
viewsQ: How to read . sql file with Java
I have a complex query in Mysql with sub-select and joins. I would like to read this script through a file .sql using the language of JPA/Hibernate (JPQL or HQL), for example…
-
2
votes6
answers19214
viewsA: Problem to publish project - Github
When we create a project on-site and apply the command git init. One branch master is automatically created. When we create a new repository on github. Does not automatically create a branch master.…
-
1
votes2
answers376
viewsA: SELECT displaying products except the results of another SELECT
According to the documentation in Mysql version 5.7(current). There are some errors that apply only to subqueries. The error described by you in the commentary is one of them. Syntax not supported…
-
1
votes1
answer162
viewsA: Relationships Laravel Onetoone?
Let’s look at what the Laravel’s documentation on relationships can tell us to solve your problem. In a relationship One-to-One there is the following example: <?php namespace App; use…
-
4
votes2
answers145
viewsQ: Leaking memory in PHP
Leaking memory or Leaky memory occurs when a computer program does bad memory allocation management such that memory that is no longer needed is not released. I’d like to understand how the Leaking…
-
1
votes3
answers1421
viewsA: foreach - Browsing CSV archive
The handling of files .csv can be made easily. There is a package called CSV that you can install via composer. I recently published an answer on this problem. This package turns the file…
-
1
votes1
answer31
viewsA: Group Last Gone Returned by Insert in database
Inside the loop of repetition save the id's in an array using the array_push. if (isset($_POST['nome'])) { $cotacao_id = []; //adicione esta linha foreach ($_POST['nome'] as $key => $value) { if…
-
2
votes1
answer33
viewsA: Can I put namespace in old classes?
As you may already know and as already described in the commentary of this question namespaces is intended to avoid name conflicts. Such conflicts may occur in relation to the names of: Classes;…
-
2
votes1
answer45
viewsA: Restriction of caractes at the end of regex
Try this way: ^https.+[\w]$ The idea is to set anchors at the beginning and end of the file: ^https: Forces the URL to start with https; [\w]$: Requires the URL to end with any numeric alpha…
-
2
votes2
answers1041
viewsA: How to check if a date is already in the correct php format?
The best way to validate dates in PHP is by using the class Datetime(). I believe that the most important thing is not to check if the date already comes in American format, but if the user is…
-
1
votes1
answer403
viewsQ: List duplicate data
I’m suffering from duplicate data in the bank and I need to list them to verify and delete them. I consider as duplicated data when the value and date coincide, as in the example below, the values A…
-
1
votes3
answers115
viewsA: Problem in the price formatting function
In Javascript exists the native method toLocaleString() to work monetary values. This already meets your specific need by making use of a locale to format the output value: var numero = 123456.789;…
javascriptanswered DNick 2,862 -
7
votes3
answers115
viewsQ: The logic behind how PHP interprets string and number concatenation?
I was doing a quiz questions for PHP certification and a question appeared that left me troubled: What will be the output of the following code fragment? <?php echo 'hello'. 1 + 2 . '34'; ?>…
-
10
votes1
answer313
viewsA: What is Data Mining?
Data mining or English Data Mining Since information became so important for decision-making, data has been stored on large scales. And with the volume of stored data growing daily, questioning…
terminologyanswered DNick 2,862 -
3
votes3
answers455
viewsA: Trying to fill an array with days from now until thirty days from now
Using only the instancia Date of javascript is enough to get the result you want. var hoje = new Date(); // Crio uma data hoje.setMonth(hoje.getMonth() +1); // aplico mais um mês var dias = [];…
javascriptanswered DNick 2,862 -
2
votes2
answers660
viewsA: A regular expression to detect acronyms of Brazilian highways
I found the question interesting and tried to inform me how the nomenclature of the highways of Brazil works. According to the website federal government highways there is a standard for defining…
-
1
votes3
answers130
viewsA: Array listing with start and end
For knowledge only. If you are working with the full date and only the hours are important. You can solve the problem easily using the Datetime. $inicio = new DateTime('2017-08-07 11:00:00'); $fim =…
-
9
votes1
answer618
viewsA: Why does the reduced version of git SHA1 code have 7 characters by default?
Git contains a plethora of day-to-day commands and workflows that you use to manage or maintain source control of a Git repository. With such command you will be able to perform basic tasks of…
-
2
votes1
answer195
viewsA: Mysql connection to Laravel 5.0
You need to put the database connection information in the file .env; In the way you’re doing 'database' => env('DB_DATABASE', 'estoque_laravel') the Portable is interpreting so: Go to the file…
-
5
votes1
answer1179
viewsA: Convert data with Javascript?
You can create an instance of the type Date in Javascript and using the method toLocaleDateString(). Capture the date in American format: let data = new Date(Date.parse('Aug 4, 2017')); To display…
-
1
votes2
answers503
viewsA: Passing $_FILES in a registration function
The $_FILES nothing more than a array. And in accordance with documentation of PHP, he says: An associative array of items sent through the current script by HTTP POST method. The structure of this…
-
1
votes2
answers2462
viewsA: Select Chained
For this to be possible you need to keep in mind that subselet need to return only one value. You cannot return two values in the same alias and may receive the error: MySQL error 1241: Operand…
-
0
votes2
answers367
viewsA: How to recover data from an html form and upload to an MS Excel file?
To handle Excel files in PHP I work with the library csv. To install the package you will need to use the commiserate. To create a file with this library is very easy. Create a header $header =…
-
0
votes1
answer199
viewsA: Autocomplete insert the value into two different inputs?
Use the JSON.parse(json) to transform the result of autocomplite on object. That way you can do it like this: var pessoa = JSON.parse(json); $('#input-nome').val(pessoa.nome);…
-
2
votes2
answers880
viewsA: PHP Generating PDF
To not overwrite the file the name must be unique in the folder. $codigo = date('YmdHis.U'); $arquivo = '-local-\form-' . $codigo . '.pdf'; $mpdf->Output($arquivo, 'F'); //Saída:…
-
0
votes2
answers1201
viewsA: How to return some* data with time interval?
You can use the SUBDATE. SELECT COUNT(primary_key), SUBDATE(data, INTERVAL 15 SECOND) FROM tabela GROUP BY SUBDATE(data, INTERVAL 15 SECOND) ORDER BY data DESC Apicated example in version 5.7. It…
-
0
votes2
answers277
viewsA: Change mysql timestamp field via php
You can set this directly in the database when creating the table. Change the row: Of: dataEntrega TIMESTAMP NULL DEFAULT NULL, To: dataEntrega DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE…
-
0
votes2
answers451
viewsA: Grab Div’s internal element on the side
The problem you’re facing is more HTML semantics than the function of click with Jquery. You can do it this way: <div id="nome" class="container"> <div class="col-10">…
-
2
votes2
answers685
viewsA: Git does not push to the master branch
The error of git refers to loss or non-reference between its branch local master and the master remote. Losing the HEAD reference. When starting the project you applied the command git init? This…
-
3
votes3
answers640
viewsA: How to resolve foreign key error 150 in Migration with Laravel?
When running the Seed command. The Laravel adopts the order of the files as the top-down execution line. That is, the migrate of categs must be before the migrate of produtos. For example: the…