Posts by rray • 66,288 points
1,220 posts
-
2
votes1
answer666
viewsA: How to reduce the INSERT script in the BD with PDO -> bindValue?
bindValue() or bindParam() pass only one value to be made bind, the alternative is on account of the execute() which allows receiving an array, the keys being the names of the indenters or number in…
-
8
votes4
answers1750
viewsA: How to create a list of dates of the year in php, skipping the weekends?
You can use Dateperiod class to assemble the desired time period, in the example I used the month of February, to know which days are weekends (Saturday and Sunday) the English one helps, because…
-
10
votes3
answers1862
viewsA: Specification and Implementation
When several companies produce similar products, some organ/institute or even group of companies come together to define recommendations or standards which must be followed by those undertakings in…
-
2
votes1
answer4170
viewsA: Insert various data into ibexpert
To documentation of Firebird suggests, use EXECUTE BLOCK to perform multiple Inserts. set term ^ ; EXECUTE BLOCK AS BEGIN INSERT INTO table1 (col1, col2) VALUES (2, 'two'); INSERT INTO table1 (col1,…
-
0
votes2
answers6064
viewsA: How to pass parameter on a route?
You should set the parameter in the url with a slider and not with query. Change: echo "<td><a href='usuarioDetalhar?nome=".$u->TabUsuariosNome."'> To: echo "<td><a…
-
8
votes5
answers631
viewsA: str_split does not work well in string containing UTF-8?
Since some php functions do not support multibyte characters, the solution is regex O.o, because in this library they are supported. You can use the dot meta character(.) to break the string into an…
-
23
votes1
answer1975
viewsA: What good is a Fatherland ( b) in a regular expression?
The \b (beta) is an anchor just like his cousins ^(alpha) and $(omega). Once added on one side of the regex will capture pattern specified at start, end or word is valid only for letters, numbers…
-
4
votes2
answers181
viewsA: Why in PHP string can turn function?
To documentation, says that if the value of the variable is the same as that of a function, following parentheses the function of that name is invoked. This is called in php variable functions…
-
7
votes1
answer1041
viewsA: What is the elegant way to read this PHP Object?
The simplest way is to indicate which key you want to iterate, thus electing the second foreach. $res = $client->RetornaRegionaisPorOperadoraDdd($params); foreach ($res->valores->valor as…
-
3
votes1
answer70
views -
9
votes3
answers82
viewsA: Help with Regex
I believe this regex ^(AD|AG|EX)[0-9]{8}$ or ^(AD|AG|EX)\d{8}$ solves the problem. At the beginning of the line is expected (a group option) AD or AG or EX followed by numbers that must repeat…
-
4
votes4
answers3915
viewsA: Knowing if there are blanks
In a regular expression the \s means blank space. You can change the [a-zA-Z-0-9-_] for \s, this will capture. if(preg_match("/\s*/",$uname)){ echo 'espaço em branco'; }else{ echo 'nome válido.'; }…
-
16
votes3
answers1114
viewsA: Working with lists without using Array() in PHP
Starting with php 7.2, a new extension to work with more rigid data structures. Existing types are: Hashable Sequence Vector Deck Map Pair Set Stack Queue Priorityqueue Yes there are other data…
-
4
votes1
answer267
viewsA: URL Friendly: Fatal error: Cannot redeclare parse_path()
Cannot redeclare Nomedafuncao Function The error is very clear, it says that the function name has been declared twice or more within the same scope in the global case, remember that it is possible…
-
6
votes1
answer237
views -
2
votes1
answer177
viewsA: Sum data with database values. Cakephp 3.0
You can use the method add() of the Datetime class, probably the cake uses it by default to manipulate dates, for it just to pass an instance of the desired period, whether in days, months, years…
-
0
votes2
answers107
viewsA: Update serial ID when a table is NULL
You can reset the value of a serial(Quence) field, with ALTER SEQUENCE nome_da_sequence RESTART WITH 1 Based on: https://stackoverflow.com/a/5272164/1342547…
-
4
votes2
answers414
viewsA: Back to top in C
Put a while before or between the main code, where it waits for a char(s/n), on the first run already initialize a variable(opcao) with s, after the operation do the writing of something like deseja…
-
1
votes2
answers53
viewsA: Does using Alternative Syntax change performance?
That would hardly have any effect on performance. PHP and other scripting languages already lose performance (compared to compiled ones) by being interpreted. Performance should be when you find…
-
1
votes3
answers83
viewsA: Date Doubt in SQL
To enter the date correctly has two important details, first leave it in simple quotes and convert the date typed by the user in the database format.
-
0
votes1
answer131
viewsA: Transaction history, how is it implemented?
The basic idea of creating a history is to have a 'controlled denormalization' in your database. In other words, you need a new table where the fields are the descriptions of the 'objects'…
-
2
votes1
answer90
viewsA: Query displaying less result than actually exists in export
Based rigidly on the details of the question the problem seems to be the do-while, $row_rcLista will only have a value after the call of mysql_fetch_assoc() which is done at the end or a blank line…
-
20
votes6
answers3379
viewsA: How to find out if the year is leap in PHP?
Another way to know if the year is leap, is to know the amount of February days, this can be done with the argument t of function date() echo date('t', strtotime('2016-02-01')); //29…
-
5
votes1
answer698
viewsA: Can too high an ID (auto-increment) be harmful?
In postgres the auto-increment field is called Sequence, an id with high number does not cause slowness in a query, the problem that can happen is that field (int maybe) quickly reach its limit in…
-
0
votes1
answer114
viewsA: Syntax error - parse_url(getenv("CLEARDB_DATABASE_URL"));
Object properties should be instances with simple values defined at compile time and not determined at runtime as function calls and other types of expressions. class Database { private $url =…
-
2
votes1
answer286
viewsA: SQL Injection with PHP + Sqlserver
There are two drivers to connect SQL Server to PDO and SQLSRV, There are several questions about the specific PDO for SQL Server, since the instation and configuration, creation of the connection…
-
5
votes2
answers168
viewsA: Clause similar to Mysql LIMIT in MSSQL
Depending on the case TOP is suitable to limit lines of a query, in newer versions there are other more flexible clashes. SELECT TOP 10 * FROM tabela. Related: Paging results in SQL Server 2000…
-
4
votes2
answers762
viewsA: How to transfer a full array of the form to another PHP file?
In this case you can transform the array into a json and recive.php return him to his original form. <input type="hidden" name="result" value="<?php echo json_encode( $array_dos_pagamentos);…
-
3
votes4
answers1852
viewsA: Reference of variable
Functions where the parameters have a & means that you must pass a variable with a simple value does not work. Passing by reference means that the passed variable will have its value changed by…
-
2
votes3
answers1372
viewsA: What is "Object-oriented" and what other methods?
Object orientation is a programming paradigm, which is a way of thinking about how to model and organize software, in addition to the resources already known as herence, polymorphism and…
-
11
votes5
answers42959
viewsA: Function equivalent to Trim (function to remove extra spaces at the beginning and end) in Python?
It has no function under the name of trim() but has the strip() that does the equivalent job. It removes the characters \n, \r, \t, \f, espaço " meu nome é wallace ".strip() Based on: Trimming a…
-
47
votes6
answers6389
viewsA: What is a legacy code?
TL;DR There is no exact definition of what is legacy, but the meaning goes in the sense of an old code or produced with technologies already retired or old techniques, almost always difficult to…
-
9
votes3
answers1938
viewsA: Test case is a use case?
A use case is a high-level description of a requirement requested by the user. A test case is a given scenario of how the system should behave in a specific location, either through inputs or exits.…
-
1
votes3
answers786
viewsA: How to take several arrays with 1 single index and put in a single array?
Create two functions to facilitate logic, one to search for all affiliates and the other to search for their status. function buscarAfiliados($id){ include 'includes/conexao.php'; $s_down = "select…
-
1
votes2
answers162
viewsA: Automatic line break with regex
This regex solves the problem, it searches for one or more spaces followed by one v or x followed by one or more spaces. $str = 'abc X edfxct'; $arr = preg_split('/\s+v|x\s+/i', $str); echo…
-
2
votes1
answer553
views -
3
votes3
answers153
viewsA: Database with php
To display all table values, leave the instruction that prints something on the screen(echo) while and not outside, otherwise only the last result will be presented. Code with problem: while ($r =…
-
5
votes1
answer2994
viewsA: Display mysqli error using die
Avoid mixing Mysqli procedural and OO style, maintain consistency In object oriented the correct form is through the property $error $sql = $mysqli->query("SELECT * FROM tabela") or…
-
1
votes1
answer39
viewsA: Move variables out of a PHP array
One option for this is to use Extract() to turn indices into variables $arg_vars = ['categoria' => 'sapatos', 'descricao' => 'sapato de couro', 'valor' => 200]; extract($arg_vars); echo…
-
4
votes1
answer688
viewsA: Ambiguous column - Laravel 5.1
The problem is in sorting, both tables have a field called id, then specify which id should be ordered, the same applies for the field nome there in the clause like. ->orderBy('id', 'asc') //…
-
3
votes2
answers245
viewsA: Data Display Issues Laravel 5.1
According to that answer, you must define the schema in the attribute $table of your model. class Cadastro extends Model { protected $table = 'cadastro.escolaridade'; } Then you can call normally,…
-
5
votes1
answer469
viewsA: How to extract only different values from an array?
Use array_unique() matching array_column() to extract only the non-repeated key values Cidade. array_column() is available from php5.5 forward if you are using a previous version, you can use that…
-
2
votes5
answers1021
viewsA: Pick first name with Regular Expression
Another way to solve with regex is: $str = 'joão da silva'; preg_match('/\[a-z]+/ui', $str, $m); The PCRE modifier u is important in this case to make the catch of accented characters otherwise will…
-
2
votes1
answer51
viewsA: Error recover json on php side
Set the name of the field that will send json, the current way is it sent without name, do data: {'dados': JSON.stringify(dados)},
-
1
votes2
answers196
viewsA: How to Write Product Checkbox and Id to Mysql
The last record is inserted because the value of $query is reactivated every time around the is, ie the mysql_query() must be inside the for to enter N records. Look at the problem: for ($i = 0; $i…
-
3
votes1
answer60
viewsA: Call class function: Minpdo::connect();
::, indicates the call of a static or constant method or property. Simply add the key plavara static. public static function connect() To properly assemble the PDO constructor, you can transform the…
-
2
votes2
answers111
viewsA: How to reuse data in a class without having to repeat this data?
To $dados and $key cire constants since the value will not change, $postFields will become a class attribute. class AllImoveis { const KEY = '82CDA6l0BBepOykevP0472xl9ZoKuIlH'; const DADOS =…
-
6
votes3
answers524
viewsA: What is Front-end and Back-end?
Unlike programming for desktops where almost all features are available on the local machine, in programming for web the most important is to understand the http protocol cycle, a request is made by…
-
12
votes5
answers56754
viewsA: What is the difference between syntactic error and semantic error?
A syntactic error is when some element of that statement is out of place, be it the lack of a line terminator, an operator in an unexpected place, etc. Semantic errors can happen from the point of…
-
2
votes1
answer329
viewsA: Display message instead of error?
To know if any function exists or has already been defined use function_exists() if(function_exists('conectar')){ $conexao = conectar(); }else{ echo 'função não foi definida'; }…