Posts by arllondias • 2,492 points
145 posts
-
2
votes1
answer2632
viewsA: Fill table with database data. (Mysql and Bootstrap 4.1)
My friend, the data is below, the problem is in the closing of your tags html..the tbody must be outside the while and the closing of tags also, within the while should be just the <tr> and…
-
0
votes1
answer339
viewsA: Trigger Problem After Update with Mysql Internal Update
Good afternoon. You cannot perform an update on the same table that is creating the trigger this can make your table enter in loop. Thus an alternative is to change when the trigger is triggered by…
-
1
votes1
answer285
viewsA: JSON in Laravel
Do it this way: $dados = $req->all(); $query = ""; if($dados['filter'] == 1) { $users = User::where('id','LIKE','"%'.$dados['search'].'%"')->get(); } else if($dados['filter'] == 2) { $users =…
-
1
votes1
answer304
viewsA: Offset and limit Mysql problem
The problem is that when you make one LIMIT with GROUP_BY or DISTINCT the OFFSET changes according to the created grouping. then the id 523800 does not reference his position in TABELA and yes its…
-
0
votes2
answers1473
viewsA: Search the database and return the value - Laravel
You’re passing the social reason to the database, Try it that way: <div class="form-group col-md-5"> {{ Form::label('cliente', 'Cliente') }} <select class="js-example-basic-multiple"…
-
2
votes1
answer243
viewsA: Save more than one PHP and MYSQL record
You must turn your form fields into one array and store the id in a field hidden. for example: <input type='hidden' name='id[]' value='<?php echo $id ?>'> <input type='text'…
-
1
votes3
answers238
viewsA: Remove all after ? in file name
Good morning. What you can do is create a bash and run inside the folder you want to rename the files by scrolling through the files and cutting the string. bash file (Rename.sh): #!/bin/bash for…
-
4
votes1
answer207
viewsA: Check current date automatically
Make a condition on WHERE of query: SELECT * FROM [table] WHERE [campo_data_expiracao] < NOW() Something like that. Anything posts its table structure so I can be more specific in the answer.…
-
3
votes1
answer34
viewsA: How to recover data from a different Where SUM?
You can add with IF within their SUM'S. SELECT us.nome as usuario, MONTH(tb.data_inicio) AS mes, YEAR(tb.data_inicio) AS ano, SUM(IF(extra = 0,TIMESTAMPDIFF(SECOND, tb.data_inicio, tb.data_fim),0))…
mysqlanswered arllondias 2,492 -
3
votes1
answer100
viewsA: Query 2 SQL tables bring all the results
You can do this using the LEFT JOIN, that will return you everything you have in the right table and what you have in the left table for example: SELECT uv.status, u.id, u.name, u.username, u.email,…
-
2
votes1
answer451
viewsA: Route restrictions with Laravel
You can use Laravel Middleware, you create a specific rule and create a grouping of routes for example: Route::group(['middleware' => ['auth','check_permissions']], function () { // TODAS SUAS…
-
1
votes1
answer264
viewsA: Registration of users with Adm logged in
Just create a new route to register users, and do not use the default route. For example: Route::post('admin/user/save', 'UserController@save')->name('admin.user.save'); Usercontroller: public…
-
0
votes4
answers72
viewsA: Show login user column sum. error
Try replacing the PDO parameter this way: <?php $_SESSION['usuario'] = 'user_login'; $sql = $pdo->prepare("SELECT SUM(valor) AS total FROM investimentos WHERE usuario= :usuario"); //Passa o ID…
-
2
votes1
answer49
viewsA: Insert into SQL if record does not exist
There is, create a index unique for the 2 columns id_usuario and idmusica and instead of using INSERT INTO use the REPLACE INTO, basically it does this automatic check. The index unique would…
-
2
votes3
answers134
viewsA: View products from multiple categories
To bring in only one line, you can use the GROUP_CONCAT and use a delimiter to return the products. the Standard is to come the way it is coming even if you had 10 products for the same category,…
-
2
votes2
answers893
viewsA: Disable ONLY_FULL_GROUP_BY at once
Good afternoon, on your terminal run the following command. SHOW GLOBAL VARIABLES LIKE '%sql_mode%'; copy the content, except ONLY_FULL_GROUP_BY. Once done, look for the configuration file MySQL…
-
4
votes1
answer121
viewsA: Filtering data in mysql
You may not use alias in a clause WHERE Or you can use your own query, that would look that way: SELECT cod, txt1, txt2 COALESCE (sum( character_length(txt1)+ character_length(txt2) )) AS tamanho…
-
0
votes1
answer38
viewsA: ABOUT MYSQL AND FOREIGN KEY
You can create a table of many for many, and reference the trip and the passengers, I will post an example. Note: I did not create the table with pk's nor fk's, because it is only for you to…
mysqlanswered arllondias 2,492 -
1
votes1
answer99
viewsA: Replace Mysql with substring
What you can do is use the SUBSTRING_INDEX, you can say that you want to cut the string from the first position when you find the 4 spaces, as follows. UPDATE tabela SET campo =…
mysqlanswered arllondias 2,492 -
1
votes2
answers56
viewsA: Create OR Update -> Mysql
Good afternoon, there is, the REPLACE native of MySQL. You can use it that way: REPALCE INTO table... If there is a record it updates the fields, if there is no it inserts in your table. Ref:…
mysqlanswered arllondias 2,492 -
0
votes1
answer1890
viewsA: How to resolve ERROR 1452 (23000) in mysql
In reality there is a "gambiarra" that you can do, but if there is error of constraint your data will not be intact in relation to foreign key, but to remedy your problem and at least you can enter…
mysqlanswered arllondias 2,492 -
4
votes1
answer501
viewsA: Mysql: Limit record recording based on value from another table
There is, you can make one INSERT from a SELECT where in your clause WHERE shall be determined that the date has to be between the tabela_a then just limit the query to 1 to enter only 1 time the…
-
2
votes1
answer3324
viewsA: Compare records between two tables in MYSQL
Do the two tables have anything in common to reference each other? for example a PK? Then just make a join and compare fields. could be something like. SELECT p1.*, p2.* FROM produtos_csv p1 INNER…
-
1
votes3
answers103
viewsA: Use BETWEEN together with IN()
Well, as far as I know this is not possible, but you can go adding OR conditions in your code instead of IN, there would be more or less this way: SELECT * FROM Conteudo WHERE '2018-03-22' BETWEEN…
-
-1
votes3
answers227
viewsA: Mysql sorting by specified value Return all values
You can do as follows, think I have a table with the name teste and its fields id and nome, you can use the ORDER BY FIELD Mysql and your query would look like this: SELECT id, nome FROM teste ORDER…
-
1
votes1
answer674
viewsA: PHP Artisan Migrate Error
Your configuration file .env is configured incorrectly, in the parameter where the name of your database should be, it is configured as localhost your file in the configuration part of the database…
-
1
votes1
answer449
viewsA: Does Mysql work with more than one index?
You can add the EXPLAIN at the beginning of his query. You’ll be able to see what’s possible keys which query you can use and which one you are using, in your case you are using only the índice…
-
2
votes2
answers242
viewsA: Consultations in Laravel
You can use the DB::table() to make the query indicating the fields you need, would be more or less this way: $positions = DB::table('positions') ->selectRaw('MAX(positions.id), devices.name,…
-
2
votes3
answers325
viewsA: Why is this php calculator not working?
So I made some changes to the code and finished the file. I put a validation for the $_GET not to give error when you enter the page. And added a switch to perform the operations, is working…
-
1
votes4
answers1196
viewsA: Different colors inside the tag H1
You can assign classes to span within H1 and swap color with css. .color1{ color: red; } .color2{ color: black } .color3{ color: blue } <h1> <span class="color1">Cor1</span>…
-
1
votes1
answer52
viewsA: SELECT similar to "INNER JOIN" cell by cell of the record?
In this structure you would have to make a Join with a OR for each field of the table tarefas to return the expected result, I would otherwise do an n:n table of tasks and operations in case one day…
mysqlanswered arllondias 2,492 -
0
votes2
answers55
viewsA: Settimeout not working, what’s wrong?
I changed and put the timeout inside the openWin function, and it worked normally. <script type="text/javascript"> function openWin() { setTimeout(function(){ var divText =…
-
3
votes2
answers9062
viewsA: Concatenate text to an existing SQL column
You have to concatenate what is stored most to tag KG: UPDATE tabela SET peso = CONCAT(peso, " KG");
sqlanswered arllondias 2,492 -
1
votes1
answer138
viewsA: How to pass a variable into a php callback with Yii2
You can use the use to access the variable $atributo within the scope of the function. public static function getModelosQuePodemTer($atributo) { return self::find() ->joinWith(['modelo' =>…
-
0
votes1
answer2151
viewsA: Calculator with 4 basic operations and create a location for the user to write their information and display in Alert after the result
just put another input and concatenate the values: <html> <header> <title>Calculadora</title> <script type="text/javascript"> function somarValores(){ var n1 =…
-
1
votes1
answer92
viewsA: Make inclusions of the respective user Laravel 5.5 Auth Standard
You can put the logged in user in the store method in your controller. for example: $data = $request->all(); $data['user_id'] = Auth::user()->id; $pessoa = Pessoa::create($data); And when you…
-
0
votes1
answer341
viewsA: How to get select to be populated based on the variable selected in another select
You have to make an appointment via ajax to fill in the second <select> Start by downloading the jquery and instantiating in your project, then open a tag script with the following code:…
-
0
votes1
answer43
viewsA: Problem when deleting relational data
Try adding your User class the following method: protected static function boot() { parent::boot(); static::deleting(function($user) { $user->documento()->delete(); }); } There is also a lib…
laravelanswered arllondias 2,492 -
1
votes1
answer221
viewsA: Authentication auth Standard
I advise you to use the softDelete Laravel to disable users. Then you don’t need to change the authentication method. and even for you to "disable" users is simpler. Ref:…
laravelanswered arllondias 2,492 -
1
votes2
answers179
viewsA: Mysql Count in substrings in the columns of a varchar field
I solved as follows, I created a precedent where, I insert the fruits in a temporary table and in the end I make a simple query in this table counting the frutas, the result is expected. consider…
-
0
votes2
answers6651
viewsA: Select higher value from the latest date
SELECT aux.* FROM( SELECT * FROM estoque ORDER BY `data` DESC, valor DESC) AS aux GROUP BY `suprimento`;
sqlanswered arllondias 2,492 -
1
votes1
answer82
viewsA: Remove a mysql column configuration
Just run an alter table, and drop the index from your table: ALTER TABLE [nome_tabela] DROP INDEX [nome_index];
mysqlanswered arllondias 2,492 -
0
votes1
answer965
viewsA: Laravel 5 Eloquent View Blade with Foreign Key?
Well, as I mentioned in the comments, the way to access the attribute is incorrect. try this way (I put the table to show in print): <table> <thead> <tr> <th>Id</th>…
-
0
votes1
answer41
viewsA: AWS Cloudsearch - I can’t find words that end with the string
After a few attempts of examples and unsuccessfully. I solved as follows: I created a text-array field and stored part of the string backwards and worked on it. example: my string is "abcde" and I…
-
0
votes3
answers281
viewsA: Longer date search for a specific ID
You can solve this by first sorting the query by date then another query limiting to 1. CREATE TABLE `teste` ( `id` int(11) NOT NULL, `data` datetime DEFAULT NULL, `nome` varchar(25) DEFAULT NULL )…
-
0
votes1
answer41
viewsQ: AWS Cloudsearch - I can’t find words that end with the string
I’m using the CloudSearch of Amazon. But I have a problem searching the words that end with a certain term, I can’t perform this type of search, it returns me only the records that start with the…
-
1
votes1
answer1525
viewsA: Is it possible to search a data in the database without knowing which table it is in?
In this Procedure it searches in all fields that are not numerical given content, first parameter you pass what you want to search and second the name of the database, it will return all found…
-
0
votes1
answer116
viewsA: SQL/PHP query
In your consultation, you are making a SELECT COUNT(*), is the only thing that is returning in its object, exchange for its alias n.*, nn.* that you will have the result of your query. If I have not…
-
0
votes2
answers718
viewsA: Mysql - Create field to insert more than one value from another table
You can save the game ID’s separated by "," here’s an example: CREATE TABLE jogadores( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, nome VARCHAR(50), jogo VARCHAR(255) ); CREATE TABLE jogos( id INT…
-
3
votes1
answer81
viewsA: Reuse the result of a function in Where
You can use the function HAVING of MySQL, so you can work with the alias called in your query, the consultation would look like this: SELECT *, round(geo(-46.000000,-23.000000,latitude,longitude),3)…
mysqlanswered arllondias 2,492