I'm using 4.1.4 Is it possible to define a connection to another database and use it with dsql ? I mean use the two connections.
Can I define a second connection in config-default.php and how can I reference it when I need ti query the other database ?
$config['dsn']='mysql://user:user#localhost/test';
$config['dsn']='mysql://user:user#localhost/test1';
Is it possible ?
Thanks
It's explained right on this page: https://agiletoolkit.org/doc/dsql/how
you can probably define it through config file but under a different key.
config.php:
$config['dsn2']='mysql://user:user#localhost/test1';
Application class:
$this->api->db2=$this->api->add('DB')
->connect($this->api->getConfig('dsn2'));
Because you're using 4.1, you should use 'DBlite' class instead, but other than than it's the same syntax.
Related
After upgrading to cakephp 4 I have this error when I try to do any query:
Return value of Cake\Database\TypeFactory::build() must implement interface Cake\Database\TypeInterface, instance of App\Database\Type\CryptedType returned
The error suggests that your custom database type class \App\Database\Type\CryptedType does not implement the required interface \Cake\Database\TypeInterface.
As of CakePHP 4.0, database type classes should not extend \Cake\Database\Type anymore, it is deprecated and will be removed completely in 5.x. For now the \Cake\Database\Type is an alias for \Cake\Database\TypeFactory, which does not implement the interface.
Your custom type classes should now either extend \Cake\Database\Type\BaseType, or directly implement the interface.
See also
Cookbook > Database Access & ORM > Database Basics > Adding Custom Types
Try clearing cache
bin/cake cache clear_all
I am trying to parameterized the topology connection in ODI to load multiple xml of same structure one by one using variable.But i am getting unknown token error.
Jdbc url :jdbc:snps:xml?f=U:/SOTI_CLOUD/#B.xml
{ #B is ODI variable having file name)
Try using #GLOBAL.B if it is a Global variable or #<PROJECT_NAME>.B if it is a project variable.
Also check what is your history setting for that variable. If it is set on "No History", make sure you are declaring/refreshing the variable within the same session in which you want to access that XML file.
Just a hunch…
For the variable to be picked up in JDBC URL you need to launch a separate scenario. Your problem might be different but make sure you have an outer loop with variable declare/refresh and whenever you refresh/increment it you launch a separate scenario (not just an interface) where you load data using such constructed URL.
Everyone.
I have been trying to create user info saving process, and bumped into this issue.
I wanted to use mysql function password() for password field, but seems no way to use MySQL function when to save data.
Is there any way to do this or simply it s impossible in CakePHP?
Thank you.
TLDR:
$this->data['MyModel']['password'] =
DboSource::expression('PASSWORD('.$password.')');
More Details:
I agree with the commenter that it's not ideal to do what you're asking, but if you really want to, you CAN run a regular MySQL query directly with the query() method. More info here:
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-query
Example:
$this->Picture->query("SELECT * FROM pictures LIMIT 2;");
Or use the method mentioned above in the "TLDR" which allows you to use MySQL functions to process your data.
Different (but recommended) method:
Here is the documentation on how to hash your password the CakePHP way:
http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#hashing-passwords
We have an application in GAE, and we are reenginering this to use Full Text. We have to index all data already in the GAE and our application also use namespaces.
We are trying to create a java procedure to be runned by administrator, who has not namespace. In other services, we have created similar java procedures, applying namespace by code, so the idea is to index all data in each namespace. (We use NamespaceFilter to control user domain.)
This is part of code:
private static final Index INDEX = SearchServiceFactory.getSearchService()
.getIndex(IndexSpec.newBuilder().setName("Actividad"));
NamespaceManager.set("userdomain1");
INDEX.add(doc);
Setting namespace is ignored.
Is this the expected behaviour? Is there an alternative way to index all the information in every namespace?
With similar code on datastore it's work fine.
A SearchService object is bound to a namespace, so you need to call NamespaceManager.set() before calling SearchServiceFactory.getSearchService(). Alternatively, call the version of getSearchService() that has a namespace parameter. See:
https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/search/SearchServiceFactory#getSearchService(java.lang.String)
We are working with a legacy database that uses SQL server uniqueidentifier columns for concurrency hence we need to use a Guid as a version column. Any idea how we could achieve this in NHibernate?
We're currently defining our mapping using Fluent NHibernate as a Guid typed property called ConcurrencyId using this snippet
Version(x => x.ConcurrencyId)
This results in the following error when creating a session
System.InvalidCastException : Unable to cast object of type 'NHibernate.Type.GuidType' to type 'NHibernate.Type.IVersionType'.
Any ideas on how this could be done, fluently or otherwise would be appreciated. We're happy to hack the source if it can be made to work.
You could try implementing a custom type implementing NHibernate.UserTypes.IUserVersionType. (I think this suggestion may pertain to a newer version of NHibernate than you are using.)
Check this...
http://ayende.com/Blog/archive/2009/04/15/nhibernate-mapping-concurrency.aspx
and the docs for the version property
http://www.nhforge.org/doc/nh/en/index.html#mapping-declaration-version
Looks like you can't use a Guid for this. Maybe just map it as a property and handle the version checks yourself.