Load a Doctrine persisted entity in async process - mysql

my application creates PDF documents from html code. For that I put the print configuration with doctrine in a mysql database and call a commandline script which calls another symfony controller action with that printjob id.
Now the problem: I got the id right now after persisting the data, but the data isn't in mysql while first process is still running.
How can I tell doctrine, to write the data immediately in the database? I tried already tips like
$em->clear()
// or
$em->getConnection()->commit()
but I does not help or caused other problems.

try to flush the data with flush like:
$em->flush()
You can flush only a single entity:
$em->flush($object)

Related

Prestashop webapi reset mysql cache by Web API or call SQL by Presta Web Service API

Hi i have problem with Presta WebService. I'm using prestashop with node (nestJS). I Created a connection with MySql database (Presta DB) with SSH tunelling. It works corectly, i can do any query, and SQL returns "OK statuses". I checked it by ssh client, (queries in temrinal) and data is updated in DB. Problem is when i want to select this data by PrestaWebService, when i pick data presta returns "old" propably cached data. On presta Admin i have ceching "off". After manually reset cache by admin panel button keep presta returns me 'old" data. Anyone know whats going on? :D
I found a problem. I used incorrect table. I queried ps_product but should ps_product_shop.

Grails auto-generate the database from the domain model

I am trying to create a simple application using Grails(3.2) and MySQL in Netbeans.
I have configured MySql in Grails project and also created a database, named "third" . After creating the domain class model, the controller (scaffolded) and the views for CRUD, my project is running but whenever I am trying to do any operation -
screenshot of error
this error is occuring. I am unable to solve this problem and also tried manually creating "Person" table, but same error occuring.
Your stacktrace clearly states that your db with name third doesn't have proper table person. But you shouldn't create this table manually (if you already had - please remove all tables from your db)
Connection seems fine but you should take a look at dbCreate value in your application.yml.
dbCreate - Whether to auto-generate the database from the domain model
- one of 'create-drop', 'create', 'update' or 'validate'
https://docs.grails.org/latest/guide/conf.html
If you are using just simple command grails run-app to start server, then you should check out the value in the environments: development block.
Paste your application.yml content (without db credentials) if you need a personalized solution.

MySQL proxy redirect Read/Write

We have a system where we have a Master / Multiple Slaves .
Currently everything happens on the Master and the slaves are just here for backup .
We use Codeigniter as a development platform .
Now we decided to user the slaves for the Reads and the Master for the Write queries .
I have been told that this is not doable without modifying the source code because proxy can't know the type of the query .
Any idea how to proceed with this without causing too much damages for a perfectly working system ...
We will use this : http://dev.mysql.com/downloads/mysql-proxy/
It does exactly what we want :
More info here :
http://jan.kneschke.de/2007/8/1/mysql-proxy-learns-r-w-splitting/
http://www.infoq.com/news/2007/10/mysqlproxyrwsplitting
http://archive.oreilly.com/pub/a/databases/2007/07/12/getting-started-with-mysql-proxy.html
something i was also looking, few month back i did something like this but i added 3 web server with master slave mysql servers, first web server enabled with mod_proxy to redirect request to read and write server all request will come to this server, if post,put or delete request come to server it will go to write server, all get or normal request will go to read server
here you can find mod_proxy setting which i used
http://pastebin.com/a30BRHFq
here you can read about load balancing
http://www.rackspace.com/knowledge_center/article/simple-load-balancing-with-apache
still looking for better solution with less hardware involved
figure out another solution through CI, create two database connections in database.php file keep save mysql server as default database connection and other connection for write only server
you can use this base model extend
https://github.com/jamierumbelow/codeigniter-base-model
you need to extend your models with this model and need to extend you model with this, it has functionality for callbacks before and after insert,update, delete and get queries, only you need to add one custom method or callback change_db_group
//this method in MY_Model
function change_db_group{
$this->_database = $this->load->database('writedb', TRUE)
}
no your example model
class Example_Model extends MY_Model{
protected $_table = 'example_table';
protected $before_create = array('change_db_group');
protected $before_update = array('change_db_group');
protected $before_delete = array('change_db_group');
}
you database connection will be changed before executing insert,update or delete queries

Error while creating a custom entity record in mscrm 4.0

I am new to using CRM.I am facing a poblem while creating custome entity record using a console application.
This console application is run with a user having "systemadministrator" privileges.
When I call objService.Creat(entity); method
I am getting the following exception
0x80042f09
SecLib::CheckPrivilege failed. Returned hr = -2147209463, User: 395a4c3e-cf59-de11-8e41-001a646ad2f9
Please let me know what caused this issue.
Thaks in advance.
Its probably because the actual webservice call is not being performed as a system administrator.
I would suggest using a WhoAmI query to check which user is actually being used, then you can correct their permissions.

Best way to connect to database for this application

I have a Delphi application which hits a database (usually MySql) every 60 seconds through a TTimer. The application is more or less an unattended bulletin board. If the network drops the application needs to continue running and connect back to the database when the connection is back. Often it might be over broadband, so chances are the connection is not always the best.
I am using the TAdoConnection component. This is opened at application startup and remains open. Whenever I need to make a new query I set the Connection to the open TAdoConnection. But I am finding this is not very reliable if there is a network drop.
What is the best way to connect to the database in this instance?
I have seen ways where you can build the connection string directly into the TAdoQuery. Would this be the proper way? Or is this excessively resource intensive? Sometimes I need to open 5-10 queries to get all the information.
Or how about doing this in the TTimer.OnTimer event:
Create TAdoConnection
Do All Queries
Free TAdoConnection
Thanks.
You should use single TAdoConnection object to avoid setting connection string to each component. Keep your connection object closed and open it when you need to access data. Something like this:
procedure OnTimer;
begin
MyAdoConnection.Open;
try
// Data access code here
...
finally
MyAdoConnection.Close;
end;
end;
You can additionally put another try/except block around MyAdoConnection.Open to catch situation where network is not available.
About second part of your question, best would be to put all your data access components in data module that you will create when you need to run data access procedures. Then you can put all your data access code in that data module and separate it from rest of the code.
You could try to open connection in OnCreate event of datamodule, but be careful to handle possible exceptions when opening connection. Close connection in OnDestroy event. Then you can use that datamodule like this:
procedure OnTimer;
var myDataModule : TMyDataModule;
begin
myDataModule := TMyDataModule.Create;
try
// Data access code here
myDataModule.DoSomeDatabaseWork;
finally
myDataModule.Free;
end;
end;