Posts by Rodrigo Rigotti • 12,139 points
344 posts
-
1
votes1
answer126
viewsA: Error using Doctrine installed via Poser
You need to use the full class name, ie the FQCN (Fully Classified class name) of it, if you want to use it. If you don’t, PHP will find that you are trying to load the class into the same namespace…
-
1
votes1
answer44
viewsA: How to use Datafixtureloader
There are some errors with your data modeling and I believe the loading of fixtures may be in any way related to this: The foreign key of the table country on the table state is the country’s…
-
2
votes1
answer871
viewsA: PHP authentication Oauth2
Oauth protocol authorization is the main form of authorization I use in my applications. Through it it is possible that customers gain access to resources of the application using access tokens,…
-
1
votes1
answer738
viewsA: Error setting up Doctrine + Zend
Missed, in the composer.json, place the package doctrine/doctrine-orm-module: "require": { "doctrine/doctrine-orm-module": "dev-master", "doctrine/doctrine-module": "dev-master",…
-
1
votes1
answer777
viewsA: Doctrine - One-To-Many Relationship
Suppose you have a table Log and a LogDetalhe. First of all you will create the entities that will be mapped to the corresponding tables: Table Log: <?php namespace AppBundle\Entity; use…
-
1
votes1
answer206
viewsA: How to check if a table date is lower than today in Doctrine - Postgresql
I will assume that you are passing the current date through the parameter $date, which is a \DateTime. Your query would look like this: $this->noticia =…
-
1
votes1
answer103
viewsA: Create list of entities in Formbuilder
It’s pretty easy. Suppose you have two entities, one User and a Permission, and a relationship ManyToMany among them: Class User: <?php namespace AppBundle\Entity; use…
-
3
votes1
answer78
viewsA: preg_match() [Function.preg-match]: No ending delimiter ' '
You placed the delimiter at the beginning of the expression, the same delimiter is missing at the end. Also, you did not escape the slash (/). '/^[a-zA-Z0-9_-]+\/{1}[a-zA-Z0-9_-]+$/' Another thing:…
-
4
votes1
answer1415
viewsA: Secure authentication with REST in PHP
Working with a REST API developed with PHP/Symfony2 that uses Oauth v2 authentication. The idea is that the consumer get a access token by means of a Grant type and that access token has an…
-
1
votes2
answers1430
viewsA: Copy files from one remote to another using GIT
Just set the new remote and give a push for the same. git remote add <nome do novo remote> <url do novo remote> git push <nome do novo remote> <url do novo remote>…
-
1
votes1
answer237
viewsA: Doctrine Insert regarding Many-to-Many unidirectional
From what I understand, you have a relationship ManyToMany between entities Contato and Local, where only the entity Local reference to entity Contato (I mean, it’s a one-way relationship). In…
-
3
votes2
answers198
viewsA: Semantical Error - Doctrine createQueryBuilder
When you reproduce in your application the relationships between tables, Doctrine already knows which columns to use to relate one table to the other. Therefore, it is not necessary to specify…
-
0
votes1
answer50
viewsA: PHP Warning: preg_match()
This error is happening because its expression must be bounded by '/' or '#'. Soon she’d be like this: $ER =…
phpanswered Rodrigo Rigotti 12,139 -
0
votes1
answer69
viewsA: Return property in a Manytomany relationship
The mistake itself has already given you the answer. Notice: Undefined Property: Proxy__cg__ JN Entity Companies Company::$getId In the following block, you call the property getId, that doesn’t…
-
5
votes2
answers214
viewsA: What happens if I don’t specify the { }?
Each if or foreach not accompanied by keys ({ and }) take into account only the next command. So the code you posted is equivalent to the code snippet below: if ($time <= time()) { if ($time !=…
-
14
votes3
answers9801
viewsQ: What’s the encoding for in Base64?
Virtually every self-respecting programming language has its implementation of encoding and Decoding from a string to a string in Base64 characters. But what is the Base64 itself for? Thank you!…
base64asked Rodrigo Rigotti 12,139 -
0
votes1
answer56
viewsA: How to do Innerjoin with related table?
Mount your query as follows: $ent = $this->em->getRepository("JN\Entity\Arquivos\Arquivo" ) ->createQueryBuilder('t') ->join('t.usuario', 'u') ->getQuery() ->getResult(); The…
doctrine-2answered Rodrigo Rigotti 12,139 -
0
votes2
answers66
viewsA: Symfony 2 create query
Trade your DQL for: SELECT p FROM blogBundle:Person p WHERE p.id NOT IN( SELECT IDENTITY(p.id) FROM blogBundle:Category c JOIN c.person p) Note the IDENTITY.…
-
2
votes3
answers163
viewsA: SELECT filtering the first results
Use the operation UNION to unite the result of two different consultations into one. The consultation before the UNION would have only the results highlighted, while the subsequent consultation…
-
0
votes2
answers74
viewsA: Unrecognised function
This error happens because when you use the method findAll of EntityRepository (of Doctrine), it returns a collection of objects - or, more specifically, a ArrayCollection. In your case, is returned…
-
3
votes2
answers767
viewsA: How to ignore a duplicate field and proceed with insertion?
Use the keyword IGNORE to ignore any errors (including duplicated lines) in your query: INSERT IGNORE INTO ... Of mysql documentation: If you use the IGNORE keyword, errors that occur while…
-
0
votes1
answer55
viewsA: Menu control
If the file index.html.twig extends the file base.html.twig, just put the block you want in the parent block. base.html.twig: {# src/RoqSys/BaseBundle/Resources/views/Default/base.html.twig #} {%…
-
1
votes1
answer194
viewsA: Implement __toString() method
You are trying to select an entity of the type Maquina but the application doesn’t know which attribute to display. You need to define in the form type which attribute to display or implement the…
-
1
votes2
answers52
viewsA: Fetch data from Entity’s to another
From what I’ve seen in the relationships of your entities, you should do the following. First search all machines, since all other entities have relationship with it, with the following DQL: SELECT…
-
1
votes1
answer2044
viewsA: query by day number of Mysql week
Use the function DAYOFWEEK in the column data. It returns the day of the week index, 1 being Sunday, 2 is Monday and so on. Source: mysql documentation…
-
0
votes2
answers98
viewsA: Comparison of dates
If you need to return true or false, a simple line solves: /** * @Assert\False(message = "Erro! Verifique as horas. Data inicial não pode ser maior que a data final.") */ public function isHoraFim()…
-
1
votes1
answer788
viewsA: How to sum the values of a specific column with the sum() function?
Add all time differences to then display the time in the desired format: SEC_TO_TIME(SUM(data_final - a.data_inicial))
sqlanswered Rodrigo Rigotti 12,139 -
5
votes2
answers2045
viewsA: Are functions and methods in PHP case-insensitive?
Functions, as well as class methods, are not case sensitive. Note: Function Names are case-insensitive, though it is usually good form to call functions as they appear in their declaration. Source:…
-
0
votes2
answers749
viewsA: I need the file to list a specific folder
Just change the following lines: // pega o endereço do diretório $diretorio = getcwd(); // abre o diretório $ponteiro = opendir($diretorio); To: // abre o diretório $ponteiro = opendir(__DIR__ .…
phpanswered Rodrigo Rigotti 12,139 -
0
votes1
answer39
viewsA: EC2 instance not loading Apache envvars file
Solved. I was trying to run the process with the wrong user - and so the file variables /etc/apache2/envvars were not being loaded.
apacheanswered Rodrigo Rigotti 12,139 -
0
votes2
answers819
viewsA: How to check if the date inside Datetime is invalid?
I found the right way. If I try to create a Datetime object from an invalid date: $data = new \DateTime('00-00-00 00:00:00'); It is sufficient to verify any errors that the manufacturer of \DateTime…
-
39
votes4
answers17554
viewsQ: What is the difference between 401 Unauthorized and 403 Forbidden?
When designing an application, it is common for me to be in doubt as to which HTTP code to return when a user does not have access to a certain resource: if it is 401 Unauthorized or if it is 403…
-
3
votes2
answers2031
viewsA: How can I compact directory except specific folder?
Use the argument --exclude of command tar: tar -pczf public_html.tar.gz /public_html/ --exclude "/public_html/wp-content/uploads/Vista"
sshanswered Rodrigo Rigotti 12,139 -
0
votes1
answer41
viewsA: Entity Repository
In its entity Intervencao you must declare the repository you have just created for it: <?php namespace RoqSys\Control\ManutencaoBundle\Entity; use use Doctrine\ORM\Mapping as ORM; /** *…
-
2
votes1
answer162
viewsA: Do not show banner with expired date
His comparison signal was reversed. One more hint: use the object \DateTime to work with dates. This makes it easier to compare dates. <?php if ($totalRows_rsBanner > 0) { do { $imagem =…
-
1
votes1
answer81
viewsA: Send data from one table to another
From what I understand, you’re looking to convert an entity of the kind Posto to an entity of the type Maquina, right? In his method createAction you are instantiating an entity of the type Maquina…
-
4
votes1
answer1166
viewsA: Convert Integer to Decimal in SQL
To return the formatted Mysql value, do so: SELECT CONCAT('R$ ', FORMAT(valor, 2)); If you want to edit the value in PHP, you should use the function number_format. <?php $valor = 12345; $preco =…
-
2
votes2
answers670
viewsA: Arrays in the clause 'NOT IN' WHERE
The clause NOT IN must be filled with the values you want to search in the field. For example, if the field is a foreign key, make a subquery by selecting only the ids of the table. Table post id…
-
1
votes1
answer2084
viewsA: How to use Github private repository in Packagist and reuse code in Composer
Yes, it is possible to use private repositories. You must declare your repository path in the key packages from Composer.json, that way: { "repositories": [ { "type": "vcs", "url":…
-
2
votes2
answers819
viewsQ: How to check if the date inside Datetime is invalid?
Work on an application with PHP 5.5 + Symfony 2 + Doctrine. In one of the tables of this application there is a field updated_at which is initially NULL. However, when I give one getUpdatedAt() in…
-
3
votes2
answers828
viewsA: List of facebook friends
According to the Graph API documentation, the only friends that will be returned will be those who use the app. Otherwise, the list will be empty even. Permissions A user access token with…
-
1
votes1
answer67
viewsA: How to create a system to list the most popular images from my application
I thought the following: You create a table compartilhamento, relating imagem and usuario. The table compartilhamento would be unique in the columns imagem_id and usuario_id, making it impossible…
-
5
votes1
answer1427
viewsA: Performance of the Eloquent of the Laravel relationship
This resource you’re talking about is called Eager loading. It checks the links between the tables and decreases the number of darlings to increase the performance of your application. At first, it…
-
6
votes2
answers3052
viewsA: Try and Catch continue running (after Exception)?
Place the block try/catch within the for: for (String f : filename) { try { String temporario[] = f.split("_"); Date data = new Date(format.parse(temporario[1]).getTime()); if…
-
0
votes1
answer111
viewsA: Convert SQL to DQL
To be able to set up a DQL, it is necessary to know the organization of the entities of its application and the relationship between them - if it is OneToMany, ManyToMany, ManyToOne or OneToOne. I…
-
1
votes1
answer49
viewsA: Inclusion of record in Manytoone with Doctrine
First you have to fetch the Categoria (and create it if it does not exist) and then link to Categoria at the Produto. // buscamos a categoria no bd $categoria =…
-
1
votes1
answer188
viewsA: How to merge identical array values, and place the different ones inside a sub-array
In hand: <?php $resultSet = [ [ 'grupoURL' => 'express', 'grupoNome' => 'Express', 'subgrupoURL' => 'aves', 'subgrupoNome' => 'Aves' ], [ 'grupoURL' => 'express', 'grupoNome' =>…
-
2
votes2
answers584
viewsA: Sort by amount of days missing to win
The field vencimento is the due date of the invoice, correct? So the logic of your code gets like this: $sql = " SELECT *, DATEDIFF(vencimento, CURDATE()) dias_para_vencimento FROM os WHERE status2…
-
8
votes2
answers1493
viewsA: Comparing prepare() vs query() with mysqli
The great advantage of Prepared statements is the following: The query needs to be parsed (Parsed) or prepared only one but can be performed multiple times with the same or different parameters.…
-
1
votes1
answer1066
viewsA: Subdomain redirection at . htaccess
This setting you should do in the virtual host configuration of your domain: ServerName testephp.com.br ServerAlias xpto.testephp.com.br Also, don’t forget to edit your file hosts to understand the…