Posts by jlHertel • 4,733 points
114 posts
-
3
votes1
answer687
viewsQ: How does the frame-Pointer work?
In the official GCC documentation there is a option that allows you to remove the frame-Pointer when it is not necessary. What the frame-Pointer ago? How removing this pointer can improve…
-
6
votes2
answers606
viewsQ: What is a tail recursion?
In that question I asked about performance. One of the users replied that the compiler does several interesting optimizations, such as inlining, Loop unwinding, tail recursion and caches. How Tail…
-
10
votes3
answers302
viewsQ: What is the cost of calling many functions?
Recently, faced with a discussion about Clean Code and programming best practices, a co-worker commented that in his previous job he had a lot of resistance on the part of the other programmers to…
-
3
votes2
answers211
viewsA: How can I add an array within an array?
Its code seems to me correct, being only with error when assigning the values to the array. You are resetting the counter whenever there is an equal answer. Right after the command else remove the…
-
1
votes2
answers316
viewsA: json_encode returns the asort() order
As @Marcos has already commented, your problem is not in the role json_encode, but rather how the properties are indexed internally by the engine Javascript. An alternative solution to your problem…
-
2
votes1
answer1651
viewsA: "No database Selected" in PHP with Mysql
The mistake No database selected occurs because a database was not selected to operate. You can select a bank in two different ways. Selecting when to connect: $conexao = mysqli_connect('localhost',…
-
3
votes1
answer223
viewsQ: What is the overhead when using Doctrine?
A few days ago I was discussing with some colleagues about performance and high availability. In the middle of the discussion one of the points raised was that when reaching a certain number of…
-
1
votes2
answers1623
viewsA: Query delete with Join mysql
As @Kenny has already responded, it is not possible to give the command DELETE at the same time that one makes a SELECT. Another solution you can adopt is: DELETE A FROM mdl_forum_discussions AS A…
-
1
votes1
answer725
views -
2
votes1
answer370
viewsA: Use of CONCAT, CONCAT_WS and GROUP_CONCAT
The command GROUP_CONCAT serves to concatenate groups when using aggregation functions such as SUM, MAX, AVG, etc.. For your query, you can only search within the fields directly. A query…
-
2
votes1
answer217
viewsA: Better BD structure with large number of data and filterable columns
As far as I could tell EXPLAIN, your query is not using any data, as you are forcing the use of functions for both sorting and grouping. An alternative to your query would be: SELECT…
-
5
votes3
answers308
viewsA: problems with distinct in mysql
Your problem is that you have 2 tables with different information and want to add them. Your solution may work, but it will take a little time. As an alternative solution I can suggest the use of a…
-
1
votes1
answer201
viewsA: How to build a reusable and manageable symfony Bundle via Composer
You are very close to creating a Bundle Properly, your only problem as far as I can see is a clear notion of dependencies and where to place the files. Dependencies The composer will always manage…
-
0
votes2
answers82
views -
0
votes1
answer656
viewsA: Doctrine 2 INNER JOIN with Subquery
Evaluating your query, I cannot see a reason to use subQuery. The data that is contained in subQuery is just the merge with the other data filter. Therefore, this query should bring the necessary…
-
1
votes2
answers210
viewsA: Sum if in Mysql Workbench
You can bring only the records that interest you and filter the others using the clause WHERE. Here’s an example of what it would look like: SELECT No_Pedido, SUM(Valor) FROM tabela WHERE cortesia =…
-
1
votes3
answers820
views -
1
votes1
answer65
viewsA: What might be causing double requests to PHP?
I noticed that some form tags were empty. Correctly putting the action in the forms solved the problem.
-
2
votes1
answer65
viewsQ: What might be causing double requests to PHP?
I am developing a system in Symfony2 and during the homologation process the client caught an error in which the system alerts keep repeating themselves. The code used is this: $objManager =…
-
3
votes1
answer49
viewsQ: When is the right time to include plugins in a program?
I’ve been following several open source projects and realized that several of them have support for plugins. Some doubts arise: What’s the best time to add plugins? I must worry about them from the…
-
4
votes2
answers130
viewsQ: What is the equivalent of a functional specification for games?
I work in a company that writes software for commercial use, usually in style sistema. To specify the software we use several documents among them: Functional Specification MER (Database Modeling)…
-
0
votes1
answer103
viewsQ: Create list of entities in Formbuilder
I have a User CRUD and a CRUD of permissions.The idea now is to add a tab to the user’s CRUD to allow selecting permissions. The initial idea is to have a complete list of all possible permissions…
-
0
votes2
answers347
viewsA: How do I set up HHVM for a manually compiled apache?
Try to replace this line: if [ \( ! -d /etc/apache2/mods-enabled \) -o \( ! -d /etc/apache2/mods-available \) ] For this: if [ \( ! -d /etc/apache247/mods-enabled \) -o \( ! -d…
-
19
votes1
answer941
viewsQ: How does C/C++ "padding work?
In several responses here at Stackoverflow I have noticed users commenting on padding in data structures. struct { int a; char b; float d; } What is this one padding (filling) that exists between…
-
12
votes4
answers172
viewsQ: Rewriting vs Incremental Improvement?
In the place where I work I am implementing new features in a legacy system. The system in question was written around 2008. Some problems encountered in the system: Database tables with 90+ columns…
-
14
votes1
answer5442
viewsQ: What is big-endian and what is the difference to little-endian?
I have a basic notion of what the big-endian and the little-endian are, but I cannot see exactly how the different form of storage can complicate portability. What portability problem occurs due to…
-
6
votes3
answers301
viewsQ: What is the advantage of using include de array vs configuration file?
I have observed some codes where the programmer does the following: /** Arquivo A.php */ return array('databaseName' => 'bancoTeste', 'port' => 5208); /** Arquivo B.php */ $configs =…
-
41
votes2
answers838
viewsQ: What is the overhead of using object orientation?
In the company where I work today we are strongly encouraged to avoid object-oriented programming for both old and new projects. For old projects I agree that it is a bad practice to start inserting…
-
1
votes1
answer958
viewsA: Printing in PHP
I’ve had to solve a scenario near this.If you use Linux you can map the network printer so that it is available through cups with the lp command. From this it is possible to call in php the lp…
-
10
votes2
answers517
viewsQ: How does Std::move work?
I would like to understand the operation of std::move. I realized that with the C++11 specification comes this new function, as well as now we have a new operator (&&). What is the semantics…
-
11
votes4
answers955
viewsA: How does Current function work?
Observing the behavior described by you makes it clear that this must be an error in the php manual. My suspicion is that as php uses the technique of Copy-On-Write, it only generates error when the…
-
4
votes2
answers262
views -
18
votes3
answers10342
viewsQ: What are Unions? Why use them within structs?
I’d like to understand the differences between union and struct. I realized that both can be accessed in the same way: u.membro uPrt->membro s.membro sPrt->membro In practice I have seen…
-
0
votes2
answers133
viewsA: Select multiple lines with PHP JSON
The second way is doing correctly what you want. The problem is when extracting the data from the database, as you are extracting all at once instead of one by one. Try the following change in the…
-
1
votes2
answers2919
viewsA: Sum of multidimensional array values in PHP
I believe that a foreach be the simplest and cleanest solution to your problem: $totalItens = 0; foreach ($_SESSION['carrinho'] as $itemID => $itemQTD) { $totalItens += $itemQTD; } echo…
-
1
votes1
answer730
viewsA: How to prevent the user from accessing without being logged in?
You cannot send headers with the function header() after output of some data. To fix your problem try this: <?php include('connect.php'); session_start(); if (!isset($_SESSION['logado']) ||…
-
11
votes1
answer1381
viewsA: Count string characters
From what I could understand of the question, you want to divide the string by comma and count the quantity, this way: $strTxt = '10,12,12,22,33'; $arrDividido = explode(',', $strTxt); $intQtde =…
-
2
votes2
answers1940
viewsA: Pass value via $_GET in include_once
Its code allows severe security failures by allowing the user to freely view any server file. I recommend you try something like: <?php $page = 'main.php'; if (isset($_GET["p"])){…
-
1
votes2
answers111
views -
7
votes2
answers5888
viewsA: Time calculation based on GMT and daylight saving time
The php Datetime class already handles the mentioned problems, just pass a Timezone that it will convert correctly; // Pega a data atual com base no horario de Sao Paulo $dt = new DateTime('now',…
-
0
votes2
answers221
viewsA: Problem in database connection
The error in your script is at the time of connection. Soon after connecting you must use the command SET NAMES utf8; This command is only required once per connection, so there is no need to use it…
-
3
votes2
answers201
viewsA: I have doubts whether this would be the right way to make a connection using the PDO class
Your script is right, however you will be creating a new connection each time you request it. Try this way using the default Singleton; Class PDOUtil { private static $oInstance; public static…
-
3
votes0
answers1928
viewsQ: Difference of QT versus GTK+ in features
Before we begin some considerations: The object of this topic is to search for facts/objects, therefore assumptions/kicks/spreads will not be accepted as answers. All responses should take into…
-
1
votes1
answer100
viewsA: Security information when entering data
The preparedStatements are interpreted by the data bank and stored there while your connection is active. When read, the database already interprets the types of data that should go in each…
-
1
votes3
answers3993
viewsA: Variable $_POST has size limit?
POST can be blocked by two configuration variables. The first already mentioned in the other answers is the post_max_size, that controls the MB limit quantity that can be received via POST. The…
-
6
votes3
answers1517
viewsQ: What to do when I get a bad_alloc error?
Before the question in question let’s assume a scenario: I have some program written in GTK+; The program uses the Operator new to allocate resources; (not to be confused with the Operator new…
-
1
votes3
answers576
viewsA: Date field in Firefox and IE
As @Lost already mentioned, it is easier to use the Datetime method::createFromFormat. I also suggest testing the date to make sure there are no errors, so the code would look like the @lost…
-
3
votes4
answers1308
viewsA: I cannot concatenate variable in a query
You can check the output of your array this way: var_dump($cod); This should give you a clear notion of what is being returned by the URL. Since the URL can be changed by the user I recommend to…
-
3
votes2
answers93
viewsA: Difference between null, Empty, 0 and false picking up the record in the database
A different way to do this directly at the bank: $sql = 'SELECT nome, idade, IF(flag_ativo = 0, "Não", "Sim") AS esta_ativo FROM tabelaExemplo'; In this example I take the fields name, age and do an…
-
6
votes1
answer736
viewsQ: What are the practical differences in C and C++ code portability?
I have been reading some open-source C code lately and have noticed that many of them become quite complex and with enough #ifdef in order to make the code as portable as possible between different…