Laravel - Show update message after update using query builder [duplicate] - laravel

When updating a table in MySQL, for example:
Table user
user_id | user_name
1 John
2 Joseph
3 Juan
If I run the query
UPDATE `user` SET user_name = 'John' WHERE user_id = 1
Will MySQL write the same value again or ignore it since it's the same content?

As the MySQL manual for the UPDATE statement implies,
If you set a column to the value it currently has, MySQL notices this
and does not update it.
So, if you run this query, MySQL will understand that the value you're trying to apply is the same as the current one for the specified column, and it won't write anything to the database.

Related

Laravel: new records do not start at next id

Let's say I'm creating a record that has an id of 2. After I deleted that record and I create a new record, the id is 3. I would like it to be 2, since the old one with 2 is gone anyway. How? Or is this not smart to do.
Btw, the id column is a NOT NULL AUTO_INCREMENT
Thanks!
I don't think its a good idea, but still you can use this
If you're using MySQL as your database:
ALTER TABLE table_name AUTO_INCREMENT = 1
this will reset your auto increment column back to 1 or in your case.
you can refer to this documentation if ever.

Change Base field odoo 9

i need to import department data to my odoo database, for this odoo can't do this because ID field is read only, all forum tell that i must change this with python module, can you help me to resolve this problem, thank you
my fiend i'm working on a case like yours now this question is not for forums this is a real work you need to create a copy of your database add the ids to every table and fix the relation between them when you finish take every thing to the postgres database :
add id to every table
create many2one field in the new tables than fix it's values by the new id and the old primary key and foriegn key
T1 One------To------Many T2
old_id old_forignkey_T1
AE1 AE1
create copy of this table : add id and many2one_fields
copy_T1 copy_T2
id old_id old_forienkey_T1 many2one_field_id
1 AE1 AE1 null
fix the values of the many2one fields according to the id ,old_id ,old_forign key :
1 AE1 -----> AE1 1
this is really hard work good luck

:APP_USER usage in SQL query. Oracle Application Express (Apex) 5.0.4

I want to use session variable :APP_USER in query in selection database statement like this:
select * from :APP_USER.data
I have users john.doe and johny.b.
I have table john.doe.data and i want to get all data from this table. Also i have table johny.b.data and when johny.b will login in, I want to get data from table johny.b.data.
I hope you understand my plan, so it is like every user have own data table and I want to display table according to logged in user. What will be the right way to do this?
I would say this would be possible but shouldn't be done. You'd be better off doing select * from apex_user.table (prefix not needed) where column = :APP_USER and having them all in one big table or having a different table (but same apex_schema) per user. How you'd go about creating this table is up to you - you could select a pseudo-table from dual and then only create it when necessary to prefent any table not found issues.
You'll no doubt run into tablespace permission issues down the line or worse - give the apex user more security permissions than it requires if you go down your intended route which will make exporting and importing a nightmare.

Best Way to Start database from particular number(id) + rails

Rails app + mysql db. I want to start the db on production from a particular id, what is the best way to do it.
The first that is coming to my mind is seeding. Is there any better way I am missing here?
Under Mysql2 in a rails app there's a database called 'information_schema' and it has a table called 'tables' and it has a record where the column table_schema is the name of your sql database and the column table_name is the name of your model's table. The column auto_increment is the next record number to use.
so (for example) for database "my_database" for model table "posts" to set that to start at 500 you would do the following SQL command...
UPDATE information_schema.tables SET auto_increment = 500 WHERE table_schema = 'my_database' AND table_name = 'posts';

Codeigniter insert and select a field in one query

I am inserting a record successfully in the database table. The primary key (member_id) is set to auto_increment. I want when I insert a member record and a new member_id is created, to retrieve that same record id immediately from the same query. Is that possible?
Regards,
$this->db->insert_id() will get the latest id from the database.
See: http://ellislab.com/codeigniter/user-guide/database/helpers.html
$this->db->insert('...');
$member_id = mysql_insert_id();
This would work also, its the standart PHP function.
http://www.w3schools.com/php/func_mysql_insert_id.asp

Resources