Posts by Marcelo de Andrade • 7,261 points
255 posts
-
1
votes1
answer448
viewsA: Ionic 2, Http request only works after second call
this.users is async, this way you won’t know when it will contain some value. Besides, you are making a subscribe under the @injectable where it should only serve the data, who should observe is the…
-
3
votes1
answer1092
viewsA: How to get the current date minus two years in mysql?
Use the BETWEEN with date_sub to subtract an interval from the date reported: SELECT * FROM table WHERE data BETWEEN NOW() AND DATE_SUB(NOW(), INTERVAL 2 YEAR);…
-
3
votes1
answer6590
viewsA: Function "change" with <ion-select><ion-option>
Like you’re already making one Two-way binding in racas, just access it as follows: export class HomePage { public racas:string; teste() { if (this.racas == "humanos") { console.log("Deu Certo!"); }…
-
1
votes2
answers737
viewsA: How to use one class functions in another?
Like the @rray said, in your new file use the methods mentioned: NovaClass.php: require 'caminho/do/arquivo/de/conexao/arquivo.php' require 'caminho/do/arquivo/de/funções/arquivo.php' class…
-
2
votes1
answer2399
viewsA: When to use ADD or COPY to copy files to a Dockerfile?
The application will depend on what you are trying to transfer to the container. According to this answer on SOen, the largest difference in the method ADD to the COPY is: Method ADD allows the…
dockeranswered Marcelo de Andrade 7,261 -
1
votes2
answers530
viewsA: Field Ionic search, need to close when user click "Go" or "OK" from Keyboard
Use your button with type="submit", so that he can be identified by device and add the go. <input type="submit" size="100" ng-model="q" placeholder="Procurar" ng-submit="fechaTeclado()" />…
-
1
votes1
answer352
viewsA: How do I increment days to a date in Ionic 2
Use the method setDate: this.myDate = new Date(); this.myDate.setDate(myDate.getDate() + parseInt(30)); console.log(this.myDate.toISOString());…
-
0
votes2
answers2495
viewsA: How do I sort the list alphabetically in the Standard?
According to the documentation, use the method orderBy. $childs = DB::table('agents') ->select('id', 'username', 'parent') ->where('id', '>=', $user_id) ->orderBy('username', 'ASC')…
-
0
votes3
answers1503
viewsA: Separate values from a variable
Using preg_split, you inform the pattern regex so that the string be divided: $variavel = "-4.08768, -63.141322 23/04/2017 22:00:00"; $split = preg_split("/\b\s/", $variavel); var_dump($split); That…
-
1
votes2
answers573
viewsA: How do I change the language of Git to English on Linux?
On your terminal, check the return of the command: echo $LANG Probably will be: pt_BR.UTF-8 Change the variable value as follows: echo "export LANG=en_US.UTF-8" >> ~/.bashrc And restart it:…
-
0
votes2
answers129
viewsA: Meaning of "$" in . htaccess
The .htaccess uses regular expressions for settings. The character $ is an anchor to delimit the end of the string informed or until line break \n. Its opposite is the character ^, which will…
htaccessanswered Marcelo de Andrade 7,261 -
0
votes3
answers88
viewsA: Merge array as PHP
array_merge and json_encode: $category[0] = json_encode(array_merge($categoria_1, $categoria_2)); var_dump($category[0]); Will return: string(94) "[{"code":"ALI000001","name":"Alimento…
-
1
votes1
answer45
viewsA: Geoip with While
Use the function file and eternal: $ips = file('ips.txt'); $gi = geoip_open("/xxx/xxx/xxx/xxx/GeoLiteCity.dat",GEOIP_STANDARD); foreach($ips as $ip) { echo geoip_country_code_by_addr($gi, $ip) .…
phpanswered Marcelo de Andrade 7,261 -
1
votes3
answers611
viewsA: Calculate values within all inputs with class='Quant'
If it’s just to iterate, add and display, you have the following option: var itens = document.querySelectorAll(".quant"); var total = 0; [].forEach.call(itens, function(item) { total +=…
jqueryanswered Marcelo de Andrade 7,261 -
2
votes2
answers944
viewsA: How to insert an item into a particular php array position?
Do it this way: $status = [ 'Visualizar' => 'Visualizar', 'Editar' => 'Editar', 'Boleto' => 'Gerar Boleto' ]; // Define a chave => valor que será inserido no array $pair = ['Status'…
-
2
votes1
answer32
viewsA: How to include php code within DELIMITER?
heredoc is a multiline string, you must concatenate the results and add them as follows: $options = ""; for ($i = 0; $i <=10; $i++) { $options .= "<option value='{$i}'>{$i}</option>";…
phpanswered Marcelo de Andrade 7,261 -
0
votes1
answer52
viewsA: Appear div according to condition
Verify the means of payment using the if: <?php if ($viewData["payment_name"] == 'PayPal'): ?> <a…
-
5
votes1
answer4837
viewsA: How to validate field when losing focus?
Use the property onblur: var ftap = "3298765432"; var total = 0; var i; var resto = 0; var numPIS = 0; var strResto = ""; function ChecaPIS(pis) { total = 0; resto = 0; numPIS = 0; strResto = "";…
-
5
votes2
answers4615
viewsA: SQL LIKE is Case Sensitive(Case Sensitive)?
I wonder if SQL LIKE is case sensitive? The command LIKE just makes comparison of string as determined pattern passed. Who is responsible for the case (in)sensitive is the collation. It is possible…
-
0
votes3
answers766
viewsA: Capture page information on facebook
As you have been informed, you can use the PHP as cURL and DOM, but this is an exhaustive option. The Facebook offers a SDK that provides ease/convenience to get information from your platform. For…
-
5
votes2
answers286
viewsA: What is the use of the varchar(0) column type?
Just like the @Marconi already mentioned as per the documentation, you can see as follows: You need only 1 bit; An unorthodox way to have a boolean, with NULL/' ' for false/true; Maintainability of…
mysqlanswered Marcelo de Andrade 7,261 -
1
votes2
answers1210
viewsA: Query between two sqlite tables
I don’t know how your business rule is defined, but when I look at it superficially I think it’s incorrect. The relationship of pedido is of 1...N, you should have an entity pedido_produto where the…
sqliteanswered Marcelo de Andrade 7,261 -
1
votes2
answers85
viewsQ: How to get element id from find method?
I am cloning a row in the table, I can insert a new value to the id, but I would like to concatenate a new value to the id existing. $("#addRow").click(function() { $clone = $('#tabela…
-
1
votes2
answers950
viewsA: Change XML tags value
If you just want to replace the values, go through the nodes and make the change as follows: <?php $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <Document…
-
1
votes1
answer37
viewsA: Date insertion problem in php mysql
You can use the following functions NOW() and DATE_ADD(), combining them you would do: SELECT SELECT NOW() AS data_emprestimo, DATE_ADD(NOW(), INTERVAL 7 DAY) AS data_prazo; INSERT INSERT INTO…
-
3
votes5
answers227
viewsA: What are strings started with @inside PHP comments?
Summary: Strings started with the sign @ are called tags. One tagpreceded by the @forms a annotation. This way it provides meta-information in a succinct and uniform way about the associated…
phpanswered Marcelo de Andrade 7,261 -
2
votes1
answer185
viewsA: Logical doubt of PHP code
This calendar itself is useless. It just increments a counter without obeying any variable that a calendar has. But let’s see: <?php function calendario() { // Define o primeiro dia como 1 $dia =…
-
3
votes2
answers923
viewsA: Constructor php
Your problem is being occasioned due to escopo variables. When referencing/accessing a method of the class in question, use the operator $this->. Another detail is that you are trying to start…
phpanswered Marcelo de Andrade 7,261 -
4
votes3
answers614
viewsA: What happens to three-digit hexadecimal colors?
According to the documentation of W3C about color units, the numerical values RGB are represented by hexadecimal notation, preceded by the character #. They may contain 3or 6 digits, being…
-
3
votes5
answers632
viewsA: PHP that returns null table fields that are neither empty nor null in Mysql
There are own functions that already make the association of the results, do not need to manually traverse and reinvent the wheel, running the risk of creating errors. Use the function…
-
4
votes2
answers57
viewsA: Placing classes in elements according to the URI passed
How did you not exemplify the possibilities of URI, you can do something by merging the functions parse_url and switch: $url = parse_url('http://localhost/testes/index.php'); // Resulta em : //array…
-
0
votes2
answers1651
viewsA: Select with JOIN
You can make a JOIN from a subselect: SELECT * FROM imovel JOIN ( SELECT DISTINCT id_imagem_imovel FROM imagem GROUP BY id_imagem_imovel ) AS imagem ON imagem.id_imagem_imovel = imovel.id_imovel…
-
4
votes5
answers590
viewsA: Remove chunk from a string
Adding one more option, you can use in a single sequence the combination of functions substr and strrpos: $text = '32137hyb8bhbhu837218nhbuhuh&3298j19j2n39'; echo substr($text, 0, strrpos($text,…
-
2
votes1
answer2164
viewsA: Datatable with JSON
In accordance with reply on Soen, you can do it this way: $(document).ready(function() { $('#tabusuarios').DataTable({ "processing" : true, "ajax" : { "url" :…
-
6
votes2
answers1130
viewsA: What is the safest way to identify that the upload file is an image?
As already mentioned the best options for @Guilherme Nascimento, I’ll make an addendum to his reply: In the PHP there is the function exif_imagetype in which it determines the type of the image…
-
1
votes1
answer31
viewsA: Problem capturing string type with Altorouter router
The expression is correct except for the alternator | which is inserted in its first position. Remove it and leave the expression as follows: ^[\pL\s]+$|u You can check it working on regex101 If you…
-
-1
votes2
answers39
viewsA: Pass an array to another format
You can do it this way: <?php function mesExtenso($mes){ return [ 1 => 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro',…
-
1
votes2
answers726
viewsA: Domxpath query with multiple classes
Yes, in the method query accepted as argument expressions, you can for example use the conditional OR for the classes you want to obtain: $content = $xpath->query('//strong[@class="imvFse…
-
4
votes2
answers1404
viewsQ: Split string into substrings and search for them in another
I’m creating a function in which I will check whether a endereço_A contains parts in a endereço_B, exemplifying: address_A AVENIDA JOÃO E MARIA address_B RUA JOÃO The result should return JOÃO,…
sql-serverasked Marcelo de Andrade 7,261 -
4
votes2
answers53
viewsA: How to give an echo in the sport?
In your example it would be something like: $modalidades = $array[0]['modalidades']; foreach($modalidades as $key => $value){ echo $value['modalidade'] . "\n"; } This will print MMA ZUMBA…
-
3
votes1
answer24
viewsA: Get content through the php class
Using the class DOMDocument together with DOMXPath you can do it this way: $html = <<<HTML <p class="p2 p2-resultado-busca"><span>Conteúdo desejado…
phpanswered Marcelo de Andrade 7,261 -
8
votes1
answer245
viewsQ: How should the data of a route be stored?
I’m developing an application where a point route will be started A at the B and wish to save the coordinates to display the route later. How should this data be saved? Monitor any changes in GPS…
mobileasked Marcelo de Andrade 7,261 -
1
votes1
answer293
viewsQ: How do I search with a text variable containing apostrophes?
Problem When searching with texts containing apostrophes, no results are found. Execution DECLARE @cidade NVARCHAR(50) SELECT @cidade = cidade FROM tabela_A WHERE id = xv SELECT campo FROM tabela_B…
-
5
votes1
answer171
viewsA: GIT - Isolate new Feature from the master branch in a new branch and reset the master branch.
If you have not done any commit in his master branch, you can effect the git checkout -b feature to create a new branch with the changes made. With that your master branch will be in accordance with…
-
9
votes1
answer128
viewsQ: How does a machine identify the type of data?
A little while ago I had a question about how a machine defines/identifies the data type. I mean, when we’re a high-level application we have the definitions that that data can be a integer, string,…
-
3
votes3
answers2939
viewsQ: Identify repeated numeric characters in sequence
With the expression [\d]{9} I can identify numeric characters if they are repeated nine times in sequence, but I only want to identify if they are the same characters, for example: 111111111 //…
regexasked Marcelo de Andrade 7,261 -
4
votes2
answers657
viewsQ: How to list NULL on a LEFT JOIN even if it returns joins?
The situation found was that: I am making a junction between representatives and sellers, and in another situation this junction is made with another sales. There are sales without sellers but are…
-
1
votes2
answers586
viewsA: Hide or delete row from table when delete record
jQuery Datatable has the method fnDeleteRow to delete a row from the table. After the return of your success AJAX, you can include for example: var tabela = $('#tabela').dataTable();…
-
4
votes2
answers125
viewsA: formatting a string with str_pad
Using the function replace, you pass three parameters: The string to be cut, the start position and the amount of characters to cut. function mb_str_pad($input, $pad_length, $pad_string = ' ',…
phpanswered Marcelo de Andrade 7,261 -
0
votes3
answers704
viewsA: You can use two columns of the same table in a WHERE
Yes, in general there is how to effect the relationship with the same table but if you have to do this, review the data structure because there is something wrong. You can use a JOIN in the same…