Posts by Rodrigo Rigotti • 12,139 points
344 posts
-
1
votes1
answer290
viewsA: Use like in the findby method to filter records?
I have worked with a system similar to yours (in which I recorded a value vector in the database through Doctrine, which in turn stored it as a serialized vector), and at the end of the accounts I…
-
2
votes1
answer312
viewsA: Variable does not work in paging
The parameter situacao is not persisted on the following pages of the pagination because they are received by the method GET, unlike the method POST initial. As a correction suggestion, change the…
-
5
votes3
answers2170
viewsA: Pass values from a popup (child) to parent page
You can do it with pure HTML. Just set the attribute target as _parent on your form: <form target="_parent"></form> This way the form will be submitted in the parent window, that is, the…
-
0
votes1
answer44
viewsA: Respect Rest does not work when trying to implement in my project
I believe the problem lies in the inclusion of autoload.php, which in turn includes all dependencies in your project. I’d do it this way: require_once(__DIR__ . '/vendor/autoload.php'); use…
-
1
votes1
answer66
viewsA: Don’t Commit Specific Line in GIT
When adding the specific file to staging (that is, the space of files that will enter the next commit), add it with: git add -p <arquivo> This way you can select the contiguous spaces of…
gitanswered Rodrigo Rigotti 12,139 -
3
votes1
answer1548
viewsA: GIT recover files (git reset --hard HEAD)
Not possible. According to the documentation of git reset: git-reset - Reset Current HEAD to the specified state Translation: moves the pointer (the HEAD) from your last commit to the desired commit…
-
2
votes2
answers692
viewsA: How do I show the notification when -30 days left to expire
If the object has an attribute with the date of entry (in this case, $dataentrada), just use it to calculate whether the object is expired or not: /** * @return bool Se o objeto está expirado. */…
-
0
votes1
answer58
viewsA: Serialize Relationships Doctrine
You only need to bring the user along with the ticket when running the query. As for the rest of the code, nothing changes. $list = $this ->getEm() ->createQuery(' SELECT t, u FROM…
-
1
votes2
answers70
viewsA: How Symfony 2 manages route conflicts with the same name
When I name the routes for my application, I usually use the following methodology: {bundle}_{controller}_{action} However, you have the option to leave the name empty. This way, the framework…
symfony-2answered Rodrigo Rigotti 12,139 -
0
votes1
answer86
viewsA: Symfony2 + Fosuserbundle - Password without Encoder
Analyzing the code of the framework, I saw that the code calls are like this: Class Symfony\Component\Security\Core\Encoder\UserPasswordEncoder: public function encodePassword(UserInterface $user,…
-
1
votes2
answers360
viewsA: Cron Job - Doesn’t Work
You need to put in cron the command as you would run it on the command line. If the executable is a PHP script, so you would run it like this: php /home/MyUserName/public_html/aaa/cron_stack.php…
-
1
votes1
answer551
viewsA: Block access to a system URL or folder path
With the directive access_control Symfony’s security configuration is quite easy to do this. See some examples in that article from Symfony’s own website: security: # ... access_control: - { path:…
-
0
votes1
answer151
viewsA: Composer giving error
You need to configure the module openssl of PHP. First download the certificate on your machine: curl -o ca-bundle.crt http://curl.haxx.se/ca/cacert.pem Then set the certificate path on php.ini:…
-
1
votes1
answer113
viewsA: Start a project on Symfony2 with Apirest
Developing a REST API in Symfony2 does not differ much (in terms of code organization) from developing a web system, for example. Some paradigms like authentication and request/response type,…
-
1
votes2
answers334
viewsA: Attempted to call Function "iconv_strlen"
The library php-iconv is not installed in the system on which you are running the system. When you call the method iconv_strlen of a given namespace and this method does not exist, PHP thinks you…
-
1
votes1
answer287
viewsQ: How to recover a deleted file by "rm" command?
I deleted a file by accident via the command rm. Is there any way to get it back?
-
2
votes2
answers3718
viewsA: How do I create my own package/project for "Composer" on github?
When you put your package as a project dependency, you need to specify if you want any Constraint version. If you have not yet versioned this dependency, you need to configure to use a branch of it…
-
0
votes1
answer148
viewsA: How to insert an object in Doctrine without persisting in other tables?
Probably the method $this->GrupoEmpresaBO->findByPk($grupoEmpresa) is returning a new company that is not persisted in the database when you try to persist the object of type…
-
1
votes1
answer184
viewsA: Search address on google maps
Use the service of Geocoding of the Google Maps API for this. Take their implementation example, it’s very easy to understand: function initMap() { var map = new…
google-mapsanswered Rodrigo Rigotti 12,139 -
0
votes3
answers861
viewsA: Run php code within a variable
The first case can be done as follows: $funcao = function($variaveis) { foreach ($vriaveis as $variavel) { echo $variavel . PHP_EOL; } } $valores = [ 1, 2, 3 ]; $funcao($valores); The second case is…
-
1
votes1
answer43
viewsA: Choose second smallest occurrence on a Rigger
I believe the following query solve your problem: SELECT * FROM Candidato WHERE BI = ( SELECT CandidatoBI FROM ClassificacaoFinal ORDER BY NotaFinal ASC LIMIT 1, 1 ) Follow a suggested edit on…
-
4
votes2
answers64
viewsA: how do I return two times using the COUNT(*) function
Just give a MIN and a MAX values, and use DATE_FORMAT to format them: SELECT DATE_FORMAT(MIN(hora), "%H:%i") as menor_hora, DATE_FORMAT(MAX(hora), "%H:%i") as maior_hora FROM minha_tabela WHERE…
-
5
votes2
answers3602
viewsA: Store credentials from a Git repository on Windows without SSH
There are two possibilities. Accessing the repository via SSH Configure me project to access the repository using a public key and private key pair. First you must change the origin to access the…
-
5
votes3
answers1011
viewsA: Performance with Multipart/form-data
According to that question on Stack Overflow, there are three values you can pass in the enctype: application/x-www-form-urlencoded (pattern) multipart/form-data text/plain The general rule is: if…
htmlanswered Rodrigo Rigotti 12,139 -
0
votes5
answers156
viewsA: Type induction for any type of object
This technique you refer to is called overloading. This concept does not exist in PHP. If you try to define two methods with the same name but with different arguments, you will have a syntax error.…
-
1
votes1
answer116
viewsA: How to extract a given index within this array with a for?
You can do it in several different ways, all with the same result: With foreach: In this case we dispensed with the index of each photo and have already received directly the sub-array: $fotos = [];…
-
3
votes3
answers619
viewsA: Timestamp limit January 19, 2038
Use the class methods \DateTime. Thus, the dates generated by your application are not limited by the architecture that PHP is running (in this case, 32 bits).…
phpanswered Rodrigo Rigotti 12,139 -
3
votes1
answer77
viewsA: Update with Join MYSQL
Us UPDATEs with JOIN, the JOINshould come before the SET. Soon, your query would look like this:: update clientes inner join usuario us on cli.nomecorretor = us.nome set cli.codcorretor =…
mysqlanswered Rodrigo Rigotti 12,139 -
1
votes1
answer798
viewsA: How to change a php object’s value
When you executed the json_decode($data), you have obtained as return an object. To change the object attribute the way you want it, it is done so:…
-
0
votes3
answers66
viewsA: How to insert an Else to display message in case you don’t have files to upload
You can do a simple check on $files: <?php $files = $obj->field('upload'); if (count($files)) { foreach ( $files as $file ) { $file_url = get_attached_file($file['id']); echo '<a href="' .…
phpanswered Rodrigo Rigotti 12,139 -
6
votes1
answer183
viewsA: GIT does not push
The problem is that your remote branch name has a hash (#) at the beginning. At the terminal, this is interpreted as a comment. Try putting simple quotes (') around the branch name: git push origin…
-
0
votes1
answer61
viewsA: how to prevent sql Injection symfony 1.4 and Doctrine 1.2?
Set the conditions for the LIKEs as arguments in the method execute: $pesquisar = Doctrine::getTable('tblicitacoes') ->createQuery('l') ->select('l.*') ->where('l.numero LIKE ? AND l.ano…
-
10
votes3
answers6678
viewsA: Equivalent to PHP LIKE
You can use regular expressions to emulate the behavior of LIKE in PHP: <?php function like($needle, $haystack) { $regex = '/' . str_replace('%', '.*?', $needle) . '/'; return preg_match($regex,…
phpanswered Rodrigo Rigotti 12,139 -
0
votes1
answer30
viewsA: How to avoid dependency dependencies in Composer?
I solved it. I can only do what I want by referencing a project tag, not by referencing dev-master: { "require": { "C": "1.*" } }
commiserateanswered Rodrigo Rigotti 12,139 -
2
votes2
answers865
viewsA: What is the purpose of $_REQUEST?
The superglobal $_REQUEST brings together all the values present in the superglobals $_GET, $_POST and $_COOKIE in a single associative array. If there are one or more values present in more than…
phpanswered Rodrigo Rigotti 12,139 -
0
votes2
answers66
viewsA: og:image with database image - symfony php
Exchange the: $response->addMeta( "og:image", "http://www.meusite.gov.br/upload/noticias/<?php echo $this->imagem;" ); ... for: $response->addMeta( "og:image",…
phpanswered Rodrigo Rigotti 12,139 -
20
votes1
answer2647
viewsQ: What are HTML5 Aria-* attributes for?
I have seen, since the release of HTML5, several attributes aria in HTML tags, for example aria-disabled, aria-required, aria-readonly, among others. What are they for?…
-
2
votes3
answers315
viewsA: Return in methods
There should be no relationship between the arguments that the method accepts, and the return that it should pass. If a method does not return any value, its return is understood as void…
phpanswered Rodrigo Rigotti 12,139 -
0
votes2
answers682
viewsA: Problem with resizing PNG images in PHP
Try passing the second parameter of imagealphablending as true: imagealphablending($image, true); Otherwise, try to create a transparent color and fill the image with this color, before making a…
-
7
votes2
answers140
viewsQ: What are numbers for when creating columns in databases?
Everyone who has ever worked with databases has noticed that, during the data modeling of a table, we can define a number between parentheses. Examples: INT(20) TINYINT(4) BIGINT(10) VARCHAR(8) If…
databaseasked Rodrigo Rigotti 12,139 -
0
votes1
answer42
viewsA: Failed to execute git status when updating Doctrine
If you have removed the file .git/index of the main project, it is probably the index of some of the dependencies that is giving problems. Delete the folder vendor and install the project…
-
0
votes1
answer299
viewsA: Error when connecting ORACLE database with PHP
From what I searched, you need to configure the reference to the Oracle server on the client machine, in the file tnsnames.ora. A file .ora would have a syntax more or less like this:…
-
8
votes1
answer116
viewsQ: How to develop an independent frameworks application?
Recently, I can’t remember where, I saw an application structure in which the core of the application, that is, its main entities, business rules etc., resided among the dependencies of the project.…
-
2
votes1
answer185
viewsA: Test autoload problem with Phpunit and Composer on Windows
The implementation you are trying is PSR-0, not PSR-4. Try to change: "autoload": { "psr-4": { "Simpla\\": [ "src/", "tests/" ] } } for: "autoload": { "psr-4": { "Simpla\\": [ "src/Simpla/",…
-
3
votes1
answer56
viewsA: System in PHP Reply in Parts
From the point of view of a TCP connection, there is no problem. What happens when you send the answer in parts, rather than a single answer, is that the transport layer creates a buffer with the…
phpanswered Rodrigo Rigotti 12,139 -
3
votes2
answers293
viewsA: Does Zend Framework work with Nginx (without apache)?
I don’t see why that would be a problem. HTTP servers do nothing more than respond to an access through a certain URL, through a certain port, with the desired HTTP content. What you need to check…
-
1
votes1
answer153
viewsA: Doctrine2 + Symfony2: How to bring more than one entity into queryBuilder
Just do it like this: $em = $this->getDoctrine()->getManager(); $qb = $em->createQueryBuilder() ->select('b, c, p, a, ci, s') ->from('MyBundle:BankAccount', 'b')…
-
1
votes2
answers409
viewsA: Unable to create the cache directory (/cache/)
You need to delete the contents of your folder cache (and also the folder logs, if necessary) and then reconfigure the folder permissions. For systems that support chmod +a: $ rm -rf app/cache/* $…
-
3
votes1
answer31
viewsA: How to concatenate strings with values from a database?
Just use the function GROUP_CONCAT mysql. SELECT GROUP_CONCAT(campo SEPARATOR ', ') FROM tabela;…
-
0
votes1
answer155
viewsA: Count records in Doctrine
Use the EntityManager to make the following DQL: SELECT v.opcao, count(v.id) FROM Voto v GROUP BY v.opcao You will receive as a result array of arrays. Give a print_r this result to see the returned…