Above issue comes after login. We are changing the lowercase to uppercase for table name and table fields. we are new for oracle 19c. we are tired to learn the oracle 19c please check below code
function check_login($uname,$pass){
#For Temp purpose password is not encrypt
$this->db->select("*");
$this->db->from("USER_DETAILS");
$where_arr=array('USER_TYPE'=>'customer','USER_LOGIN_NAME'=>$uname,'USER_STATUS'=>1);
if($pass!=""){
$where_arr['USER_LOGIN_PASSWORD']=md5($pass);
}
$this->db->where($where_arr);
$res=$this->db->get();
return $res;
}
Related
I have this error
SQLSTATE[42S02]: Base table or view not found: 1146 `Table 'skin_db.destination_destination_detail'` doesn't exist `(SQL: select * from `destination_destination_detail` where `destination_id` = 8)`
Where in fact I only have destinations and destination_details table. but the error is looking for destination_destination_detail table?
I really do not understand why.
Destination model
public function details(){
return $this->belongsToMany('App\Destination_detail');
}
Controller
$destination = Destination::find($req->destination_id);
$destination->details()->sync($req->provinces);
If you are using the relation many to many you must create another table it's name destination_destination_detail with columns:
destination_detail_id
destination_id
both of them are foreign key
I'm using Laravel Auditing Package to trace changes on my models.
I want to get a specific column of the foreign key in it's primary table before recording the events (create, update, delete) in the audit table.
There is a way the package helps get all the attribute of the foreign key, it's called Audit Transformation but it generates an error for me when displaying the details in the table i want to know if there's any eloquent model method to get the specific column info i need instead of using getattribute() method which gets the entire row of the item_id.
Audit Transformation Method
public function transformAudit(array $data): array
{
if (Arr::has($data, 'new_values.item_id')) {
$data['old_values']['item_name'] = Item::find($this->getOriginal('item_id'));
$data['new_values']['item_name'] = Item::find($this->getAttribute('item_id'));
}
return $data;
}
This is how it's stores in the database ephasis on the item_name.
{"item_id":"1","qty_received":"2","delivered_by":"John",
"received_by":"Abi","supplier":"Stores","date":"2019-11-26","item_name":{"item_id":1,"item_name":"Toner","colour":"Black","status":"Active",
"created_at":"2018-10-25 17:55:26","updated_at":"2018-10-25 17:55:26"}}
And this is the Item table schema
So in my scenario i'd want to store the item_name as Toner not the entire row of the item_id
Any suggestion will be welcomed, thanks in advance.
Add ->item_name->item_name after the function of Find.
if (Arr::has($data, 'new_values.item_id')) {
$data['old_values']['item_name'] = Item::find($this->getOriginal('item_id'))->item_name->item_name;
$data['new_values']['item_name'] = Item::find($this->getAttribute('item_id'))->item_name->item_name;
}
I need to use a SQL VIEW in a query using Room Persistence Library.
Using Commonsware's answer here I've been able to run a raw SQL statement to create the view during DB creation.
Room.databaseBuilder(context, MyDatabase.class, DB_NAME)
.addCallback(new RoomDatabase.Callback() {
#Override
public void onCreate(#NonNull SupportSQLiteDatabase db) {
super.onCreate(db);
db.execSQL("CREATE VIEW view_name " +
"AS SELECT [...] "
);
}
})
.build();
The VIEW is actually created on the SQLite DB and works fine, but I cannot refer to the it in my Dao's #Query because I get a compile-time error:
Error:(100, 48) error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: view_name)
Any idea on how to let Room to know about my view or to ignore the error?
UPDATE 17/12/2018
Version 2.1.0 and higher of the Room persistence library now provides support for SQLite database views:
https://developer.android.com/training/data-storage/room/creating-views
(see D-D's comment)
UPDATE 15/12/2017
Be aware that this solution actually breaks DB migrations.
Problem is with the Entity primary key that obviously doesn't exist on the view, so migration is not valid.
See CommonsWare's comment for a possible hacky workaround.
ORIGINAL ANSWER
It seems that this is not possible at the moment using Room.
Anyway I've done it using a workaround: I've created an Entity with the same name and columns as the view (only the name is actually mandatory), this will create a table on DB and allow you to use that table name in queries without compile-time errors.
Then during Room DB creation I DROP this entity's table just before the CREATE VIEW.
Room
.databaseBuilder(context, DueDatabase.class, DB_NAME)
.addCallback(new RoomDatabase.Callback() {
#Override
public void onCreate(#NonNull SupportSQLiteDatabase db) {
super.onCreate(db);
//Drop the fake table and create a view with the same name
db.execSQL("DROP TABLE view_name");
db.execSQL("CREATE VIEW view_name " +
"AS SELECT [...]"
);
}
})
.build();
I have a database table erp_product and database table oc_product, I need them to have the same value in all records. I created a route called atualizador.
Route:
Route::get('/atualizador', 'JoshController#updatetables');
And a function in Controller
public function updatetables()
{
$oc = OCProduct::all();
$erp = Product::all();
return view('admin.atualizasite')->with('message', 'Banco atualizado com sucesso!');
}
Can I create an update with eloquent usage like two tables from different database?
Any suggestion?
It works, I used DB :: statement, Thanks guys.
im using c# with Entityframework to access to a Oracle database. After update the entities on the model, i'm just adding a new entity do a dbset, then i call dbcontext.SaveChanges(), and a exception is thrown "Input string was not in a correct format."
As Oracle does not have autonumbers, i've changed the "StoreGeneratedPattern" to Identity and the table where i'm tring to add a row have a relation to other table.
i'm missing something too basic?
some ideas?
myentity oNew = new myentity(){...}
ctx.myentity.Add(oNew);
ctx.SaveChanges();