I have two database users and magento.
magento is reside at remote machine in LAN.
and users is reside at my local machine.
connection between them and fetching data from that magento database is working fine
but I want to do pagination on magento's table data.
simple displaying it is done, but for pagination we require model name, and how can i have model of other database??
// in controller action
$this->Vendor->changeDataSource('vsdatabase');
if($this->changeDbSource('vsdatabase'))
{
$magento_data = $this->Vendor->query("SELECT * from admin_user");
$this->set('products',$magento_data);
}
and changeDataSource($newdb) is defined in model file
and changeDbSource($database='default') in controller
so how can I solve my problem with pagination?
I have completed fetching data without pagination.
or any other option to do this?
Thanks,
You're going about this the wrong way..
You should create a new database configuration for the external database, call it say.. $vendor_db in app/config/database.php
http://book.cakephp.org/1.3/en/view/922/Database-Configuration
Then you need a model for your new connection. Tell the model what database connection to use with $useDBConfig:
class Vendor extends AppModel {
var $useDbConfig = 'vendor_db';
}
http://book.cakephp.org/1.3/en/view/1058/useDbConfig
This way, in your Vendors controller you can make database calls using standard cakePHP functions, including paginate.
$this->paginate('Vendor')
cakePHP model functions should almost always preclude you from writing your own queries. Generally speaking, if you think you have to write a query, you're probably doing something wrong.
Related
Within my Django app I currently only have one DB, under settings it is default. What I want to do is port over all of the Auth tables created by Django to a separate database, Ill say SiteAuth for now.
I have copied all of the auth tables over to the SiteAuth db, but I am not sure how to integrate those changes within the site. I know I am going to have to add another db the databases section of settings, But I am not sure how to do the migrations, or how to specify which database I want to query.
How would I do the migrations? how would I specify which database I want to query? how would my models.py change?
Thanks for all the help!
you need to write a router. Check this:
https://docs.djangoproject.com/en/2.2/topics/db/multi-db/
I would recommend to keep the auth in the default db, and move the other stuff in the new one. On the other questions the docs are very descriptive, but to summarize you need to add stuff to the Meta class of your models.
We have databases like the below image.
In Application, Once a new company registers a new database created for the company. Consider there might be multiple schemas.
Schemas would be the same for all company.
I am new to NestJS. Currently, we are managing this scenario using function call we pass database name it will create a new connection with DB using mongoose and iterate all defined models in from the database and create an object which used by application-wide.
Now, We need a new level of development. we choose NestJs.
How can we deal with this kind of technique with nestjs?
What should be a design pattern for this kind of flow?
How we will deal with Email for the registered company?
Single Page Application which is developed in angular JS. I Just wanted to know the audit of the user activity in the front end timeline based on the users interaction with the database.
The database layer is done using HIBERNATE and controller layer with JERSEY Restful web-services. I wants to Audit the user operations on add,modify,delete etc in the UI while interacting with the hibernate.
I have gone through some posts , Some suggests JPA API for hibernate auditing, some suggests Spring DATA to achieve it. I Wanted the audit data to be shown up when user interacts with the system as well as arranging it in the back-end also.
Help me from the best architecture perceptive,flow or road-map to achieve it and also give me some learning tutorials.
Thanks in advance
Based on the assumption that by auditing you mean to be able track the change history that is made to entity rows at the database level, then yes Hibernate has an extension called Hibernate Envers that does this for you.
You can find documentation on Envers here
The jist is that you simply need to annotate your entities with #Audited either at the class level or on a per property level, supply a few configuration parameters at the time you construct either your EntityManagerFactory or SessionFactory and make sure you have the appropriate tables created in your database.
Once the revision tracking has started, you can then easily query for audit changes by using the org.hibernate.envers.AuditReader interface. See the documentation for how to obtain this.
Our CakePHP 3 app (a POS System) is going to use subdomain approach where clients will share a common code base but run on individual databases.
2 things from the config (app.php) file will be unique to each instance : database details and security salt. These details will be stored in a table of main site database (wordpress) and I want to load them based on the subdomain opened. (abc.maindomain.com or xyz.maindomain.com)
I am not sure where should I implement this stuff in the code. bootstrap.php seems to be the only viable solution for now. What are experts' thoughts over this? I plan to store those details in a session once loaded so that system doesn't need to call main database everytime.
I'm exploring all the options to persist user settings. The artilce in the url User-specific settings files for a windows form application: local xml file or database convinced me to store the settings into a db as my application is a standalone communicating with a DB. Is there any provider class like RegistrySettingsProvider to persist the data into database.
No - there isn't anything directly comparable. I'd look at the user settings as just another kind of data to store in the database. Use the same methods to store the user settings as you do the rest of the application's data.
I recommend NHibernate for your data layer. Just set up a mapping file and the database table and let NHibernate handle persisting your data to the database. Use that for all your database storage throughout the app and see how little database code you need to write.
I afraid no because your use setting is very application specific and hence there is no general to do the persistence.
You might want to consider one of the following two approaches:
Serialize your user setting class as a string, and store that string as a blob text column in one of your table.
Create a table schema that maps to your user setting, and persist the setting according to each column.
I would prefer the first approach because of its flexibility.