Posts by Rodrigo Rigotti • 12,139 points
344 posts
-
3
votes3
answers9800
viewsA: Mysql Workbench - Create Database based on EER Model (Forward Enginner Options)
It’s this screen here? Come on, one by one: DROP Objects Before Each CREATE Object: deletes tables before re-creating them Generate DROP SCHEMA: deletes the database/schema before creating it again…
-
1
votes1
answer113
viewsA: Convert text to image using Zend Framework
You have five different libraries to work with PHP images: Cairo, Exif, GD, Gmagick and Imagemagick. Surely some of them should serve your purposes. What you can do is use Composer to add some image…
-
2
votes1
answer2656
viewsA: What is the appropriate folder architecture to apply to a web project?
Usually in any type of project (PHP, Java, Ruby etc.) you have a public folder, accessible to the general public through a web server (for example, the folder web/ or the folder public/). In…
-
1
votes6
answers3344
viewsA: How is an agile way to add and remove code comments in VIM?
To remove comments starting at #: :%s/\s*#.*//g To remove comments starting at //: :%s/\s*\/\/.*//g To remove blocks of comments surrounded by /* and */: :%s/\/\*.*\*\///g…
-
3
votes2
answers761
viewsA: How to create and remove aliases in GIT
I will assume that you work in Linux or OSX environment. These aliases you put in your file ~/.bashrc (in the case of Linux) or in the file ~/.bash_profile (in the case of OSX). Edit them in Vim (no…
gitanswered Rodrigo Rigotti 12,139 -
7
votes3
answers4980
viewsA: What is the usefulness of the til operator in CSS?
According to the W3, for translation of the Maujor: 14.4. Brother combination element in general The sibling combination element in general consists of two single selectors separated by a sign of…
-
8
votes2
answers6308
viewsA: Optimize Mysql tables
Not everything is about running OPTIMIZE. Maybe you should start dividing your tables into smaller tables, normalize the data, decrease queries, analyze the efficiency of queries (with EXPLAIN),…
-
2
votes3
answers157
viewsA: Why does this violate Strict Standards?
The child class method parameter has to be exactly the same as the parent class method parameter. In object-oriented programming, SOLID is an acronym for Single Responsibility, Open-closed, Liskov…
-
0
votes1
answer133
viewsA: How to use a local directory as a dependency?
Dscobri. The directory to be used as a dependency needs to be a Git project (git init), even if I’m not in any remote repository. Then just commit. In addition, you must reference the correct branch…
-
2
votes1
answer133
viewsQ: How to use a local directory as a dependency?
I am designing a relatively large project in my company that consists of several packages in PHP. Some of these packages are normal packages and others are Bundles of Symfony applications. When we…
-
2
votes2
answers194
viewsA: What are database model migrations?
Migration is the procedure that changes the state of a database. As well as source code, the structure of a database changes as we develop an application tied to that database. For example,…
-
1
votes4
answers514
viewsA: Error in mysql_fetch_object
The function mysql_fetch_object returns an object of type \StdClass. To return an array, use the function mysql_fetch_array.
-
3
votes4
answers1855
viewsA: PHP/Codeigniter error "Array to string Conversion"
To measure the size of an array, the function to be used is sizeof, and not strlen (that measures string size). Follow a suggested change to your code: public function distribuicaoprodutos() {…
-
4
votes1
answer1510
viewsA: How to do multiple simultaneous inserts with php
Concatene the Inserts with ; or do INSERT as follows: INSERT INTO tabela(coluna1, coluna2, coluna3) VALUES (valor1, valor2, valor3), (valor4, valor5, valor6), (valor7, valor8, valor9) ...…
-
1
votes1
answer307
viewsA: UPDATE and SELECT at the same time (locked)
Use SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; to enable the NOLOCK. SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; -- sua query... COMMIT; To make this feature count for…
-
2
votes1
answer134
viewsA: How to change the Prepared Statement wildcard value?
Use the functions bindParam and bindValue. For example: $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)"); $stmt->bindParam(':name', $name);…
-
1
votes3
answers1343
viewsA: Empty multiple tables in a single run
According to the syntax of TRUNCATE in mysql documentation, this is not possible. What you can do is pass several commands of TRUNCATE in the same query, separated by a semicolon: TRUNCATE tabela1;…
-
1
votes1
answer373
viewsA: Load "php.ini" specific for a sub-domain
Use the directive PHPINIDir in the virtual host configuration of the site for which you want to specify a php.ini personalized. <VirtualHost 1.2.3.4:80> PHPINIDir /var/www/web1…
-
0
votes2
answers898
viewsA: Time Comparison Problem with mysql
It seems to me that the problem lies in the modeling of your table. Theoretically, it should be something like this: hora_dia_inicio hora_dia_fim tempo_entrega 0 2 55 2 22 40 22 24 55 And then the…
-
1
votes1
answer2000
viewsA: Count grouping by week
There is a Mysql function that gives you a concaternation between the year and the week of the year, called YEARWEEK(). Use it to get what you want. SELECT count(id), YEARWEEK(data_tarefa) anosemana…
-
2
votes4
answers3403
viewsA: Check data in the database according to the date
Supposing data is in format DATE, DATETIME or TIMESTAMP, $condicaoData should be in format YYYY-MM-DD. You can do two things: provide the date in the received format and use the function DATE_FORMAT…
-
1
votes5
answers140
viewsA: Is it possible to scroll to git bash?
Enable the mode Quick Edit. In Properties, on the flap Option -> Edit Option -> check the option Quick Edit and give OK. (solution found in a Stack Overflow post in English, test and tell us…
-
6
votes2
answers7355
viewsA: Is it better to parameterize your Preparedstatement even if the value is fixed?
That using Prepared Statements is safer than concatenating the parameters directly into the query, that’s true. However, if the parameter is fixed, I do not see why to pass it as a parameter of…
-
4
votes3
answers331
viewsA: Unknown cause error: "Syntaxerror: invalid range in Character class"
Regular expression lists are based on the ASCII table (http://www.asciitable.com/). According to this table, a is character number 97 and Z is the character number 90 - because of this, it makes no…
-
10
votes1
answer1754
viewsA: How to get around the expired page problem?
Browser claims expired page because the request page is the result of a POST (done on the login page). What is certain is that after you validate whether the person’s login is correct, redirect it…
-
3
votes2
answers921
viewsA: Text input box on the right
I found the answer in another question in the Stack Overflow (in English). See if it fits:…
-
3
votes4
answers482
viewsA: Disabled button modified using firebug
Yes, the ideal is that the validation is done both in client-side and server-side. You can try to block the button from being enabled by a javascript code, but by Firebug itself you can disable the…
-
3
votes8
answers64831
viewsA: How to check if a checkbox is checked with PHP?
In the array of $_REQUEST (I don’t know if your form method is GET or POST), just check if your checkbox name key is there, with the corresponding value.…
phpanswered Rodrigo Rigotti 12,139 -
0
votes3
answers485
viewsA: How to select separate records on multiple pages of a PHP pagination?
Suppose you have, in client-side, a series of records, each associated with a checkbox: <ul> <li><input type="checkbox" name="messages[]" value="message1">Mensagem 1</li>…
-
8
votes4
answers4814
viewsA: Get value from external HTML TAG "<link>"
Try fetching the data within an HTML by navigating the DOM, not using regular expressions. It may happen that, hypothetically, there is a link within another link and because of that, his expression…
-
7
votes4
answers4295
viewsA: Way to make a comparison between three variables
I think the most efficient is: if ($a === $b && $a === $c) { return true; } return false; Remembering that == test whether the variables have equivalent values (for example, a 0 amounts to…
-
2
votes8
answers59138
viewsA: How to raise a number to a power without using the Math. h library?
Think about how you would do it in a math test. x^(1/2) amounts to sqrt(x). With that in mind, the rest of the implementation is pretty quiet. Remark: as recalled, in fact x^(1/2) amounts to sqrt(x)…
-
0
votes5
answers411
viewsA: How to avoid a comparison by brute force?
I believe the best option is to use Overloading in your class. So you implement the same method several times, each accepting a type of parameter. For example: public class Leitor() { public String…
javaanswered Rodrigo Rigotti 12,139 -
1
votes4
answers2553
viewsA: Database structure for multi-language system
How I would do this implementation: It would have a table containing all expressions in all languages - for example, messages. It would have a second table containing the languages that the…
-
4
votes5
answers436
viewsA: Refactoring: When is a method "too big"?
I have not read the method, but class methods, in the context of object-oriented programming, should always offer a single functionality. Thus, its application becomes more uncoupled, the methods…
-
1
votes1
answer353
viewsQ: How to execute a command via proc_open and not wait for the execution to finish?
I own a Symfony2 project that generates a PDF from an HTML with Bundle KnpSnappyBundle, that is dependent on Bundle KnpSnappy and which, in turn, makes the abstraction with the executable…
phpasked Rodrigo Rigotti 12,139 -
2
votes7
answers30383
viewsA: How to dump a Mysql database with PHP?
Use the crontab for scheduling backup jobs, and compressing the banks with gzip, which makes the size of backups much smaller. To schedule tasks with the crontab, Assuming you have the proper…
-
21
votes8
answers75484
viewsA: Error - "Cannot Modify header information - headers already sent"
This type of error usually happens because your application’s server has already started sending the body of the response to the current HTTP request. The header, which by definition comes before…
-
0
votes2
answers522
viewsA: How to integrate Facebook login with ZF1 Auth?
If you have two authentication systems, their purpose is the same: to allow your user access to the system. Login authentication is the most common, and with a simple form (and the appropriate…
-
1
votes4
answers702
viewsQ: What are the best practices of representing SQL within PHP code?
PHP program together with SQL (mainly Mysql) for a long time, I already have some experience, however I never found a good solution for this: what is the best way to insert SQL within PHP code?…
-
1
votes5
answers12657
viewsA: How do I protect PHP code from theft and piracy after deploying?
What you can do is "compile" the code to run on a Hiphop VM (HHVM). This practice is more and more common (for the most diverse purposes) and may serve for what you want.
-
1
votes3
answers6510
viewsA: How to access a server via SSH without using password?
This is common in AWS, when you use a . pem file to log in to the machine. The command is something like: # ssh -i ~/.<usuario>.pem <user>@<host> ... and you are already logged in.…
-
1
votes2
answers246
viewsA: Switch TAB indentation to spaces in Vim
To change on all lines: :%s/\t/ /g Or, if you want to change only on the current line: :s/\t/ /g
vimanswered Rodrigo Rigotti 12,139 -
0
votes4
answers698
viewsA: Does anyone know a good tutorial on ACL in Symfony 2?
You can use Fosuserbundle to manage users of your application. In the application’s security settings it is possible to define roles, for example, ROLE_MASTER, ROLE_EMPRESA, ROLE_DEPARTMENTO,…