Posts by gmsantos • 17,221 points
395 posts
-
5
votes1
answer900
viewsA: How to traverse lines of a SELECT in a STORED PROCEDURE in SQL Server?
Apart from CURSOR and WHILE I don’t believe there’s any other way. On the Oracle we have a FOR loop, but this does not exist in SQL Server. However I do not see the real need to have even more ways…
-
2
votes1
answer788
viewsA: Creating and using Libraries in Laravel 5.1
Using Laravel or any other modern framework you will notice many differences with Codeigniter. He "stopped" in time and did not follow the novelties that have emerged over the years in the PHP…
-
1
votes2
answers6305
viewsA: How to insert an image using Laravel Blade 5.1
The HTML component was removed since the Laravel 5 of the core framework. You need to include the Laravel Collective if you wish to use {{ HTML::image('img/picture.jpg') }} or use directly HTML:…
-
0
votes5
answers1057
viewsA: Problem with in_array()
You are checking a multidimensional array and the in_array() is not recursive, that is, it will not look for the value in the second level of the array. Before checking, loop to iterate the array:…
-
1
votes1
answer51
viewsA: Check whether array is associative in a class
I thought here of some ways to solve this problem. The first is to use a global function. Not everything in your application needs to be object-oriented or there is only one right way to do things.…
-
1
votes1
answer70
viewsA: Create Fake Relationship/Relationship in Laravel model
Return an instance of DB is not the same as an instance of Post. It may look the same but it’s completely different. Change your code to return an instance of Post: $post = Post::where('titulo_url',…
-
3
votes4
answers301
viewsA: How to find hashtags in a string and store them in an array?
Another way is to marry in regex the tag with hashtag and separate only the group with : function extractTags($mensagem) { // Casa tags como #dia #feliz #chateado // Não casa caracteres especias…
-
1
votes2
answers422
viewsA: Correct use of Laravel Mutators 5.1. Is it possible to use it in this way described below?
Use the with to bring the related model: Tabela::with('relationMethod')->get(); app/Table.php <?php namespace App; use Illuminate\Database\Eloquent\Model; class tabela extends Model { public…
-
5
votes1
answer407
viewsQ: How to create a new configSections in App.config
I am working with an application that currently uses the section appSettings to obtain application settings through ConfigurationManager.AppSettings. But I would like a more complex structure for my…
-
7
votes3
answers48471
viewsA: Apache does not start the service in windows 10
Your problem may be that door 80/443 is already occupied by another process. You can use a utility to confirm who is using these ports, such as Currports. You can also find out from the command…
-
7
votes12
answers28737
viewsA: What are the ways to iterate an array in PHP (without foreach)?
In fact, a loop for does not work well with arrays with non-numeric indexes, but it is possible to circumvent this if "reset" as Keys but are not important, with array_values. $array = array(…
-
11
votes12
answers28737
viewsA: What are the ways to iterate an array in PHP (without foreach)?
You can use the array_walk: $array = array( 'stack' => 'Overflow', 'linguagem' => 'Português', 'tags' => array('PHP', 'Iteração', 'Array') ); array_walk($array, function ($value, $key){…
-
4
votes2
answers655
viewsA: Problem Migrating Mysql Database to SQL Server
The resource of Database Migration of Workbench only works for import from other databases to Mysql itself, not the other way around. Note that the session target only it is possible to specify a…
-
1
votes2
answers108
viewsA: What is the "array" option for in the app/config/Session.php?
As part of documentation: array - Sessions will be stored in a simple PHP array and will not be persisted Across requests. This driver will store the Session in a simple array, and will not persist…
-
9
votes2
answers1835
viewsA: What is the difference between 'string' and r'string in Python?
What is this r that precedes the string declaration? The r before the quotes comes from raw, that is, the string will be interpreted as a literal string. In a raw string, escape characters such as…
-
8
votes1
answer823
viewsA: PSR-4 on an MVC project or not?
My recommendation would be to directly use a autoloader that implements the PSR-4, as included in Composer. In addition to being a standard already fully adopted in the community, the configuration…
-
11
votes3
answers794
viewsQ: Which CSS properties prefixes are compatible with Edge?
With launch of Windows 10 Microsoft eventually retired Internet Explorer, changing the default browser to the Microsoft Edge. To support CSS properties that have not yet been standardized by W3Cen,…
-
26
votes1
answer6947
viewsQ: When to use Cordova or Xamarin?
When researching a bit about platforms for application development mobile I came across Xamarin and Cordova. Both proposed to develop a single code base for apps running on Android, iOS and Windows…
-
3
votes1
answer75
viewsA: In Laravel, which file is indicated to use Macrotraits?
In bootstrap/start.php I think it’s a bad idea, this file is used to load the autoload and start the Laravel classes themselves. In the app/start/global.php would also work, but you would lose some…
-
5
votes2
answers111
viewsQ: Combining column value with Mysql
I am working on a report in Mysql where I need to show a percentage of several events that occurred with a group of entities. The structure of my table is as follows: | id | eventoA | eventoB |…
-
1
votes1
answer22
viewsA: Strange error in class method call
Your error is in trying to execute a property that does not exist null. Static methods nay execute the constructor method of the class, as nothing is instantiated. See that example: <?php class…
-
2
votes3
answers638
viewsA: How to run PHP in interactive mode?
Iterative PHP mode does not work very well on all systems (Windows). In those cases I like to use the Psysh. In addition to running in iterative mode, it includes functions such as autocomplete,…
-
5
votes2
answers126
viewsA: Syntax error when trying to access static method on object saved in property!
This happens because the PHP interpreter has some inconsistencies and does not support some semantic combinations. Fortunately these inconsistencies have been corrected in PHP 7, as you can see in…
-
4
votes1
answer1274
viewsA: What is the difference between array_walk and array_map?
In addition to one using reference and another returning a new array, see the signature of both methods: bool array_walk ( array &$array , callable $callback [, mixed $userdata = NULL ] ) array…
-
4
votes2
answers3054
viewsA: Format CPF column with regular expression
What you want is possible using the function regexp_replace: SELECT REGEXP_REPLACE(cpf, '([[:digit:]]{3})([[:digit:]]{3})([[:digit:]]{3})([[:digit:]]{2})', '\1.\2.\3-\4') AS cpf_formatado FROM…
-
2
votes1
answer70
viewsA: Problems sorting an array
Instead of sort(), use the natsort(). Of documentation: This function is an implementation of the algorithm that sorts alphanumeric strings in the way a human would maintain key/value association.…
-
4
votes2
answers1419
views -
6
votes1
answer111
viewsA: How to use {} instead of opening PHP tags?
Probably the views of this site are using Smarty. He is a template engine under the table converts the file to PHP markup from the simplified syntax used by it. See one example using PHP and another…
-
1
votes1
answer168
viewsA: Mysql.Entity version compatible with Mysql 5.6
I found the following table on mysql documentation. It shows which version of Mysql for Visual Studio is required according to server version, Connector and Visual Studio: MySQL for Visual Studio |…
-
1
votes1
answer411
viewsA: @Yield does not display content
From the comments I noticed some problems that need to be fixed. In the route file, you set twice a route to Site\HomeController@home. The route '' ends up being unnecessary, so you can eliminate…
-
2
votes1
answer532
viewsA: Default field to select in Illuminate/html
This problem was recently solved in Laravel Collective. {!! Form::select('size', ['dados' => 'no', 'seu' => 'select'], null, ['placeholder' => 'Selecione uma opção']) !!} If you are not…
-
7
votes4
answers847
viewsA: How to generate indented code?
If your goal is just to view the source code, you can use the Developer tools that comes with the browsers. In Google Chrome, press F12 and will open at the bottom the indented code correctly: Now…
-
1
votes1
answer757
viewsA: Modelfactory is not generating $Faker data for some tables
On your table email there is the field mailchimp_id which has not been defined in its Model Factory and also has no value default in Migration. I modified your Factory here and it worked:…
-
3
votes5
answers10525
viewsA: Show every day between two dates
A common practice in Data Warehouses is the creation of a dimension (usually a table) with all possible dates. You can create a table with all dates in your database and recover the result by a…
-
10
votes1
answer21225
viewsA: Parse error problem: syntax error, Unexpected T_VARIABLE
The mistake Parse error: syntax error, Unexpected T_VARIABLE means that PHP was not expecting the definition of a variable at any given time. This error may occur in some situations, but your…
-
0
votes1
answer126
viewsA: Backup SQL SERVER database
If you already have SQL Server running on your local machine one output is to use SQL Server Import and Export Wizard to import the remote tables to your local instance. Select the remote server as…
-
3
votes2
answers4562
viewsA: Count number of files in folder
As the function glob() returns an array, just count the number of indexes with the function count(): $pasta = 'imagens/'; $arquivos = glob("$pasta{*.jpg,*.JPG,*.png,*.gif,*.bmp}", GLOB_BRACE); echo…
-
3
votes1
answer64
viewsA: How to var_export export export array in short syntax
The var_export continue exporting variables in format array() in latest versions. Although PHP 5.4 introduces the simplified syntax of bracketed arrays [ ], the use of arrays in the format array()…
-
21
votes3
answers847
viewsA: Does merging PHP files into one only increase performance?
Generate PHP code in which the classes used are in the same file would be "faster" than having them "scattered" by directories? Theoretically performing a single file decreases access to the disk,…
-
0
votes2
answers449
viewsA: How to expedite VB.net database searches / Access97
Have you tried changing your query to one INNER JOIN ? SELECT TOP 10 Pedidos.Número, Clientes.RazaoSocial As [Cliente], vendedores.nome As [Vendedor], Pedidos.Data As [Data], Format(Pedidos.Valor,…
-
3
votes6
answers17792
viewsA: Accentuation problem while recovering records in SQL Server
Try to use the same Collation throughout your application. Since you cannot change the Database, set up PHP to work with Latin-1 (ISO-8859-1): header('Content-Type: text/html; charset=iso-8859-1');…
-
1
votes1
answer160
viewsA: Get url parameter in GET request using REST
PHP does not work natively with this URL format and with so many Packages so they perform the function of routing, I don’t see much point in redoing the wheel. What you can do is use some component…
-
1
votes2
answers59
viewsA: Determine execution according to home page
Because HTTP requests are isolated, we need to use other resources to point to the source page. They all involve defining an identifier of the source page that will be passed to the next page. Some…
-
1
votes1
answer2778
viewsA: CSS Blade Laravel
You can create this in a different way by creating a @section only for CSS on its home page. It’s interesting to put views that all pages will use: // trecho do arquivo layouts/master.blade.php…
-
3
votes1
answer232
viewsA: Why should I use File::copy, if PHP already has copy?
The idea of frameworks is to create a high-level layer to facilitate the use of some language resources, separating their code from a specific implementation thus resulting in a low coupling of…
-
3
votes2
answers174
viewsA: How to send queries simultaneously to test Transactions efficiency in Mysql?
You can use the mysqlslap to test their transactions. Create a file .sql with the cases you want to test. Your script would be something like: > mysqlslap --concurrency=5 --iterations=5…
-
12
votes2
answers7005
viewsA: What are the differences between die, Exit and __halt_compiler?
The functions die() and exit() are equivalent, according to the documentation, and serve to terminate script execution by displaying an additional message. Already the __halt_compiler() has a…
-
0
votes2
answers1020
viewsA: Does Netbeans support Django?
In accordance with the link you posted, Netbeans does not officially support Python, that is, support for this language is maintained by the community. This project is a community driven effort.…
-
1
votes2
answers227
viewsA: SQL Query, Join 4 tables, 2 group_concats + conditional, Help
There was no missing parentheses? SELECT C1.id_cliente, C1.nome, C1.fones, C2.emails, C2.endereco, C2.numero FROM ( (SELECT cliente.`status`, cliente.id_cliente, cliente.nome,…
-
4
votes5
answers2278
viewsA: Is it safe to use $_GET in PHP? (Parameter in URL)
Note: According to the documentation, $_GET is not obsolete, what is actually obsolete is the $HTTP_GET_VARS. Using parameters per URL is necessary in several cases and it facilitates in the user…