Posts by Rodrigo Rigotti • 12,139 points
344 posts
-
1
votes1
answer688
viewsA: PHP Simple HTML DOM Parser works without id or class reference?
Yes. You must use a property called XPath, indicating the path of an element in the DOM (Document Object model). To catch the XPath of an element, simply access the Elements tab of Developer Tools…
-
5
votes2
answers1023
viewsA: Database modeling problem
The problem with your data model is that there is no track record of teams a seller was a part of. That is, if the seller was part of 10 teams throughout his history, sales will be accounted for…
-
2
votes2
answers377
viewsA: Generate diff patch between two branchs
It’s okay if the commits are in different branches. What you need is just to know the hash of each commit. And then just turn the following command: git diff <hash-1> <hash-2> >…
gitanswered Rodrigo Rigotti 12,139 -
3
votes3
answers6367
viewsA: How to disable Developer Tools options in Chrome
Actually Developer tools is not disabled, but Facebook discourages doing anything there, as many laypeople don’t know what it is. They went on to display this message because of malicious users who…
-
1
votes2
answers68
viewsA: file_exists to check news
The function file_exists works only for local archive. It’s right to use the curl to make the connection to the desired page and check if the answer is valid. Generally check the code of status of…
phpanswered Rodrigo Rigotti 12,139 -
1
votes1
answer454
viewsA: Problems with wp_mail( ); wordpress function
If I’m not mistaken, Digital Ocean instances do not come with a previously installed SMTP server. You will have to login to the instance via SSH and install the server manually, then use it in…
wordpressanswered Rodrigo Rigotti 12,139 -
1
votes3
answers1870
viewsA: Search book details with Google Books API in PHP
In the section Performing Search, it is said that it is possible to specify the name of the book (or part of it) using the parameter intitle. For example: http…
-
1
votes1
answer594
viewsA: How to display related table data organized by topics
As far as I’m concerned, you’re searching the data the right way but you’re using a single loop to travel them. You need a loop external to traverse data and loops internal to go through data from…
-
9
votes4
answers58562
viewsA: Css comments with // instead of /* */
Comments on CSS with // do not exist. The correct syntax is to use /* */ in all cases. One line comment: body { /* margin: 0; */ padding: 0; } Comment from n lines: /* body { margin: 0; padding: 0;…
-
1
votes2
answers773
viewsA: Include_once and right directories - php
If you don’t use namespaces, the best way is to always take into account the absolute path of the system files, and not the relative paths - that is, the path of one file relative to another. Also,…
-
4
votes1
answer1467
viewsQ: How to avoid misuse of a REST API?
I am developing an application that is composed of three parts: Backend (BD + API), developed with Symfony 2 + Doctrine 2 IOS client Android client Most client requests for the API must be…
-
2
votes1
answer327
viewsA: GIT project interface for local server
The most adopted solution in these cases is the Gitlab. You set up a local web server, install Gitlab on it, configure users, initialize repositories, and then upload local repositories to remote…
-
1
votes2
answers255
viewsA: Select repository-specific columns in Doctrine 2
What you can do is make you return a custom repository to a model specific, rather than returning the EntityReposity standard of the Doctrine. In this custom repository, which inherits the class…
-
3
votes2
answers1063
viewsA: Left John returning more records
The LEFT JOIN, by definition, brings the rows of the table even if they are null. What is likely to be happening in your case is that not all rows in the table principal have corresponding lines in…
-
0
votes2
answers2919
viewsA: Sum of multidimensional array values in PHP
Beyond the foreach, it is possible to use a closure (anonymous function) to sum: $contagemTotal = array_reduce($produtos['carrinho'], function($contagemTotal, $contagem) { return $contagemTotal +=…
-
1
votes3
answers199
viewsA: How to capture the result of an execution of doctrine2?
The class EntityManager of Doctrine, which uses the classes that implement the interface Connection (that is, the classes PDOConnection, DB2Connection, MysqliConnection, OCI8Connection and…
-
0
votes1
answer509
viewsA: How to fetch data from another entity using Doctrine 2
After rereading the question I saw that it is a Many-To-One association. Come on then: you need to create two classes - Produto and Categoria – and map relationships using notes. The relationship…
-
1
votes2
answers407
viewsA: Organize folders, subfolders and acquisitions of an array?
Whereas you’ll always have that hierarchy: m folders with n files within each of them and no subfolder: <?php // vetor de arquivos $arquivos = array( 'Big Hero 6/Big Hero 6.avi', 'Big Hero…
-
2
votes1
answer149
viewsA: Optimize SQL Query in three tables
In hand: SELECT c.categoria, p.idproduto, p.nome, p.valor, fp.* FROM categoria AS c, produto AS p, foto_produto AS fp WHERE p.ativo = 1 AND p.idcategoria = c.idcategoria AND fp.idproduto =…
-
0
votes1
answer55
viewsA: Table in SVG file
You need to inform the XML namespace you want to import using the attribute requiredExtensions tag foreignobject, and not just the first tag of that specific XML: <foreignobject x='10' y='10'…
-
0
votes3
answers788
viewsA: Get line from a file
Use the function file. Ex: <?php $linhas = file('arquivo.txt'); This function returns the contents of the file with one line per array entry. From there, just manipulate the line you want through…
phpanswered Rodrigo Rigotti 12,139 -
5
votes1
answer29
viewsA: Access the same page in multiple "pathname"
Use mod_rewrite. As this you can redirect the requests from: demo.com/page/IagoBruno for demo.com/page.php?username=IagoBruno or: demo.com/page/RodriggoDell for…
phpanswered Rodrigo Rigotti 12,139 -
1
votes1
answer1984
viewsA: Redirect HTTPS to HTTP using . htaccess
On sites where I want to force the user to always access the HTTP version instead of HTTPS, we do so: <VirtualHost *:443> ServerName site.com.br Redirect permanent / http://site.com.br/…
apacheanswered Rodrigo Rigotti 12,139 -
0
votes1
answer150
viewsA: Display bd record by id in a modal Foundation 5 (pop-up)
Let’s look at the error: Fatal error: Call to a Member Function Row() on a non-object. The mistake says row() is being called in a non-eobject, which would be the protocol sought through the method…
-
3
votes2
answers1171
viewsA: Can you use the same query and define two different "ORDER BY"?
I see two possible solutions to this problem: Continue using two separate queries and create indexes in the columns CLIQUES and VOTOS. By using indexes your database manager system will bring both…
-
39
votes3
answers57155
viewsA: Charset iso-8859-1 and utf-8 compatibilization problems
Not possible. So, when an HTML page is loaded, the charset used in it is reported: <meta charset="UTF-8"> Therefore, all content loaded on the page should ideally be loaded on that charset -…
-
1
votes1
answer172
viewsA: Linking Tables to Cakephp
You should not reference the table of posts by title for the simple fact that more than one post can have the same title, causing an inconsistency in your data model. Even if you define the title as…
cakephpanswered Rodrigo Rigotti 12,139 -
2
votes1
answer364
viewsA: Use filter_input(FILTER_SANITIZE_NUMBER_INT) in an array with integer type entries
Place FILTER_REQUIRE_ARRAY as the fourth argument of the function filter_input. $post['turmas'] = filter_input(INPUT_POST, 'turmas', FILTER_SANITIZE_NUMBER_INT, FILTER_REQUIRE_ARRAY);…
-
2
votes1
answer448
viewsA: Problems upgrading from access token
Your mistake is on that line: request.addQuerystringParameter("refresh_token", oldToken.getToken()); The token you need to use to generate a new pair is the refresh token, not the access token.…
-
1
votes1
answer397
viewsA: The mysql start command path is not set?
A Mysql server must be initialized (as well as restarted, terminated, etc.) via the command line. Normally this command is at: /etc/init.d/mysql To start the server, just pass start as argument, so:…
-
3
votes1
answer146
viewsA: Can the controller send an email?
Power, can. But not recommended. Comparing the two methods, it seems to me that the difference is just passing the client separate from activity, which to me there would be no need since one is an…
-
2
votes1
answer275
viewsA: ORM Mapping error in Doctrine 2
I was able to solve by setting the last parameter ($useSimpleReaderAnnotation) of the call createAnnotationMetadataConfiguration as false: $config =…
-
0
votes2
answers662
viewsA: How to select all BD data and do a repeat word count?
Suppose the array $registros be the records you pulled from the database. We will create an array $tags with the count for each tag. $tagCount = []; foreach ($registros as registro) { $tags =…
phpanswered Rodrigo Rigotti 12,139 -
2
votes1
answer264
viewsA: Find commit in which file was deleted
If you know the path of the file that was deleted, use: git log --all -- <arquivo> Otherwise, use: git log --diff-filter=D --summary | grep delete Reference: here.…
gitanswered Rodrigo Rigotti 12,139 -
1
votes2
answers1757
viewsA: Restful Web Service Authentication with PHP
Normally access tokens usually, depending on the endpoint setting, have a lifetime of one hour. The URL is not usually the safest method, as it is exposed even on secure connections. The ideal is to…
-
5
votes5
answers26088
viewsA: Registration problem (Column Count doesn’t match value Count at Row 1)
You delimited all query variables with a single pair of single quotes. String Cadastro = (" insert into livros ( ISBN, titulo_livro, autor_livro, editora_livro, consignacao, preco, quantidade)…
-
3
votes3
answers1429
viewsA: Generate sequential number within one month
I wrote an algorithm that generates the id increment if there is already a case in the database for the current month and year - otherwise it generates the first id. public function geraId() {…
phpanswered Rodrigo Rigotti 12,139 -
3
votes2
answers40
viewsA: Database normalization with 'parent services' and 'child services'
The third normal form (3FN) seeks to eliminate reductive values in the data of an application. In your case, the column information nivel is reductive, since by the column itself cod_pai you know if…
-
3
votes2
answers1246
viewsA: Scroll through dates by printing a field for each
Create an object of the type \DatePeriod passing as parameters the initial and final date, in addition to a \DateInterval of type "P1D", that is to say a one-day period between the dates. Your code…
-
1
votes1
answer195
viewsA: Using libraries downloaded by Composer in Zend Framework 1
When you declare the dependencies of a project through composer.json, somehow you have to include these dependencies in your project. Suppose the composer.json of your project be so: { "require": {…
-
0
votes1
answer423
viewsA: Visualisar box interface in virtualbox
From what I understand, you want to use the virtual machine interface, not just interact with it via the command line (after running vagrant ssh), right? Usually the virtual machines are headless,…
-
5
votes3
answers2723
viewsA: Domain without www does not work
This setting is not from .htaccess, yes from the virtual host. In the file you configure your domain (for example, /etc/apache2/sites-enabled/dominio.conf), just configure the ServerAlias:…
-
5
votes2
answers8689
viewsA: When to use address table in database
In my opinion, the best option is to have an address-only table, which relates to a neighborhood table which relates to a city table and which ultimately relates to a state table. Entities that have…
-
3
votes1
answer155
viewsA: Allocation of responsibilities in the MVC
Think of controllers as just one of the entry points for your application, so they should have as little code as possible. I say this because there may be other input points such as commands, Apis…
-
1
votes3
answers10545
viewsA: Regular Expression White Space
A suggestion: DOCUMENTO:(\d+)\s*(\d+)\/(\d+)\/(\d+) Example of implementation: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexMatches { public static void…
-
2
votes1
answer198
viewsA: Doubt about the Doctrine dbal project structure
You’re doing this almost the right way. When you install a dependency on your project, it often has other dependencies. In the case of doctrine/dbal, as you can see in packagist (or directly, on its…
-
2
votes3
answers212
viewsA: Error at end of Symfony installation
This error happens because you, in fact, have not set any route mapped to /. If you had installed the AcmeDemoBundle would have an initial route to explore, which would be the /hello/{name}. The…
-
4
votes3
answers269
viewsA: How to reduce the capture of groups in a regular expression?
I believe this is the best (and most simplified) expression for your case. Remember that not only does a regular expression have to be efficient, but easy to understand.…
regexanswered Rodrigo Rigotti 12,139 -
0
votes1
answer515
viewsA: Convert Nginx redirect rule to . htaccess
Try the following settings: RewriteEngine On RewriteRule ^/ajax/(.*)?$ /app/controller/ajax/$1.caj.php RewriteRule ^/data/(.*)?$ /app/controller/data/$1.data.php RewriteRule ^/([^/]*)/favicon.ico$…
-
4
votes3
answers3330
viewsA: Convert a date to the name of the day of the week
Just to complement: you can do this using object orientation or procedurally, and Felipe’s response fit in the latter case. To do so using objects (and the class DateTime PHP), just do it this way:…
phpanswered Rodrigo Rigotti 12,139