Moving data from 1 pair of table to another similar pair

2014-03-25 Thread Sam


I have 2 similar pairs of tables (Table1 and Table2, TableA and TableB).

Table1 has many Table2. Table2 belongs to Table1. In other words, there is 
a one-to-many relationship between Table1 and Table2. TableA and TableB has 
the same one-to-many relationship as Table1 and Table2.

I would like to move a row in Table1 plus all the associated rows in Table2 
to the matching table pair TableA and TableB.

What is the best way to transfer the table row and the associated rows? Do 
I save each row to the new table one by one using save() or is there a way 
to save all the rows at one go using saveall()?

Is it a problem to use saveall() to do the data transfer if the table 
fields are similar but not exactly the same. Between the table pair, some 
rows are the same and some rows are different.

I am using Cakephp 2.4.5. Thank you for your help.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: cake 3 - best practice to develop backend app with one or more frontend apps sharing cake lib

2014-03-25 Thread mark_story
Have you considered using plugins? If the 'backend' and 'frontend' 
application run in the same process/server you could probably use plugins 
quite nicely. If they run on separate servers it gets a bit more 
complicated.

By using a plugin you can use basic composer features to install the 
backend code into the frontend one and avoid having to define the full 
classname everywhere as you can use Plugin.Foo style class names in most 
places (if there are className options that don't support Plugin.Class let 
us know)

-Mark

On Tuesday, 25 March 2014 19:19:20 UTC-4, bato wrote:
>
> Hi there,
>
> I played a bit with new ORM and now I'm starting to port BEdita to Cake 3.
> BEdita is a Semantic Content Management Framework developed with cake 1.3. 
> The backend is a cake app that can manage multiple frontends data. Every 
> frontend is a cake app too that uses a set of api that are exposed from 
> backend app.
>
> Backend and frontend apps share cakephp lib and backend models, behaviors, 
> helpers are reachable from frontends since they are added to paths with 
> App::build().
>
> Now I try to figure out as reproduce the "same" situations with cake 3 and 
> I would ask some advice.
>
> I'm starting creating the backend app with composer, then I added frontend 
> app by hand beacuse I want to reuse cake core installed in backend app.
> So my directory structure is
>
>- bedita: containing app (Bedita\\ namespace) and vendor with cakephp
>- frontend-app: clean cakephp app skeleton
>
>
> ├── bedita
> │   ├── Bedita
> │   ├── Module
> │   ├── Plugin
> │   ├── Test
> │   ├── tmp
> │   ├── vendor
> │   └── webroot
> └── frontend-app
> ├── App
> ├── Plugin
> ├── Test
> ├── tmp
> ├── vendor
> └── webroot
>
> To use cake and bedita in frontend app I managed App/config/paths.php and 
> App/config/bootstrap.php
>
> In App/config/paths.php I added the path to bedita folder and modified 
> CAKE_CORE_INCLUDE_PATH to use that.
> In App/config/bootstrap.php I change composer autoload path to 
> bedita/vendor/autoload.php 
> and added to it App namespace
>
> // Use composer to load the autoloader.
> if (file_exists(BEDITA_CORE_PATH . '/vendor/autoload.php')) {
> $loader = require BEDITA_CORE_PATH . '/vendor/autoload.php';
> $loader->addPsr4('App\\', APP);
> }
>
> After that in frontend app PagesController I am able to do:
>
> $images = TableRegistry::get('Images', [
> 'className' => 'Bedita\Model\Table\ImagesTable'
> ]);
>
> The only thing I had to pay attention is how to add behavior in Bedita 
> Table objects. I had to specify the behavior className to avoid errors 
> using those Table objects in frontend app.
>
> $this->addBehavior('BeditaObject', [
> 'className' => 'Bedita\Model\Behavior\BeditaObjectBehavior'
> ]);
>
>
> So I ask you CakePHP core dev/guru if it is the right way to handle this 
> case or if you have some suggestion or advice.
>
> regards
> Alberto
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


CakePHP 2.5.0-beta Released

2014-03-25 Thread mark_story
The CakePHP core team is proud to announce the immediate availability of 
CakePHP 2.5.0-beta[1]. This is the first beta release for the 2.5 branch. 
The 2.5.0-beta release contains several new features that improve CakePHP's 
performance, security and ease of use. When done, this new version will 
replace the 2.4.x branch. A migration guide is provided in the book [2] and 
we encourage you to read it if you are upgrading from an older version.

### New features

While the migration guide[2] contains all the changes in 2.5.0, here are a 
few we are excited about.

 Cache::remember()

This method allows you to implement read-through cache operations. For the 
passed cached key, it will first look for any cached data that is still 
valid. If not found, a callback method will be executed and its return 
value stored under the cache key.

You will find this useful for reducing the amount of repetitive code around 
checking for cache misses.

 Improved Memcached support

A new Cache engine has been added to provide support for the php extension 
ext/memcached, which is the faster and better supported extension for 
utilizing this popular key-value database. In introducing this new adapter, 
we have deprecated the old Memcache engine and plan for its removal in 3.0.

 CompletionShell

For shell environments that support command completion such as bash and 
zsh, we have provided a cake shell that will help you get command and 
options completion for your cake shells by hitting the tab key. If you have 
ever wondered what shells are available, or what options they can take, 
this might be for you. Make sure to check the documentation for more 
information on how to set this up.

 Security::encrypt() and AES encrypted cookies

If for any reason you are storing data in cookies that should not be 
changed by the user, you can now use AES encrypted cookies. This utilizes 
the new AES-256 encryption offered by the Security class to prevent various 
classes of attacks, such as cookie tampering.

 Consistent priorities in global and local events

One limitation in previous CakePHP versions was that listeners attached to 
the global EventManager would always be called before any other local 
listeners, despite the priorities. CakePHP 2.5 unifies the priority queue 
between global and local event listeners. With a single unified set of 
priorities, you can implement more complex and complete aspect oriented 
programs.

The API docs[3] and cookbook have been updated to reflect the changes and 
updates for 2.5.0.


The CakePHP core team would also like to welcome Brian Crowe (bcrowe) to 
the team. Brian has been actively improving the cookbook, API docs and code 
during the development of 2.5, and 3.0.

A huge thanks to all involved in terms of both contributions through 
commits, tickets, documentation edits, and those whom have otherwise 
contributed to the framework.

### Links

* [1] https://github.com/cakephp/cakephp/releases/2.5.0-beta
* [2] http://book.cakephp.org/2.0/en/appendices/2-5-migration-guide.html
* [3] http://api.cakephp.org/2.5

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


cake 3 - best practice to develop backend app with one or more frontend apps sharing cake lib

2014-03-25 Thread bato
Hi there,

I played a bit with new ORM and now I'm starting to port BEdita to Cake 3.
BEdita is a Semantic Content Management Framework developed with cake 1.3. 
The backend is a cake app that can manage multiple frontends data. Every 
frontend is a cake app too that uses a set of api that are exposed from 
backend app.

Backend and frontend apps share cakephp lib and backend models, behaviors, 
helpers are reachable from frontends since they are added to paths with 
App::build().

Now I try to figure out as reproduce the "same" situations with cake 3 and 
I would ask some advice.

I'm starting creating the backend app with composer, then I added frontend 
app by hand beacuse I want to reuse cake core installed in backend app.
So my directory structure is

   - bedita: containing app (Bedita\\ namespace) and vendor with cakephp
   - frontend-app: clean cakephp app skeleton
   

├── bedita
│   ├── Bedita
│   ├── Module
│   ├── Plugin
│   ├── Test
│   ├── tmp
│   ├── vendor
│   └── webroot
└── frontend-app
├── App
├── Plugin
├── Test
├── tmp
├── vendor
└── webroot

To use cake and bedita in frontend app I managed App/config/paths.php and 
App/config/bootstrap.php

In App/config/paths.php I added the path to bedita folder and modified 
CAKE_CORE_INCLUDE_PATH to use that.
In App/config/bootstrap.php I change composer autoload path to 
bedita/vendor/autoload.php 
and added to it App namespace

// Use composer to load the autoloader.
if (file_exists(BEDITA_CORE_PATH . '/vendor/autoload.php')) {
$loader = require BEDITA_CORE_PATH . '/vendor/autoload.php';
$loader->addPsr4('App\\', APP);
}

After that in frontend app PagesController I am able to do:

$images = TableRegistry::get('Images', [
'className' => 'Bedita\Model\Table\ImagesTable'
]);

The only thing I had to pay attention is how to add behavior in Bedita 
Table objects. I had to specify the behavior className to avoid errors 
using those Table objects in frontend app.

$this->addBehavior('BeditaObject', [
'className' => 'Bedita\Model\Behavior\BeditaObjectBehavior'
]);


So I ask you CakePHP core dev/guru if it is the right way to handle this 
case or if you have some suggestion or advice.

regards
Alberto


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: I want to prevent users to access other users data. Now I am trying using isAuthorized() function, but not working. Getting '$controller does not implement an isAuthorized() method" error.

2014-03-25 Thread euromark
See http://www.dereuromark.de/2011/10/05/common-cakephp-problems-and-solutions/ 
for some ideas
Basically you check the session Auth.User.id against the one of the record 
you want to access
If they dont match throw an Exception or redirect away with some error 
flash message.


Am Dienstag, 25. März 2014 10:51:10 UTC+1 schrieb Rahul Dhavale:
>
> In app controller added '$this->Auth->authorize = 'Controller';' in before 
> filter and added public function isAuthorized() {} function in users 
> controller. I don't want to use ACL. 
> e.g If logged in users edit profile url is 
> http://localhost/abc/users/edit/1 then I want to prevent to acces 
> users/edit/2 data. Please help me.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Console/cake schema pitfalls ?

2014-03-25 Thread SpazzyV
Have you considered using the Migrations plugin from 
CakeDC? https://github.com/CakeDC/migrations It handles the actual changes, 
rather than having a 'full' copy as schemas do. 

I think the issue you are seeing is more about the datasource definition, 
as that is where it gives the datatype to general type definitions ... for 
example:

public $columns = array(
'primary_key' => array('name' => 'IDENTITY (1, 1) NOT NULL'),
'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'),
'integer' => array('name' => 'int', 'formatter' => 'intval'),
'float' => array('name' => 'numeric', 'formatter' => 
'floatval'),
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d 
H:i:s', 'formatter' => 'date'),
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d 
H:i:s', 'formatter' => 'date'),
'time' => array('name' => 'datetime', 'format' => 'H:i:s', 
'formatter' => 'date'),
'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 
'formatter' => 'date'),
'binary' => array('name' => 'image'),
'boolean' => array('name' => 'bit')
);


That is from the sqlsrv.php datasource, so it really only uses those and 
then converts back and forth. This allows you to write your migration / 
schema in mysql, but I can instantiate it in mssql. If you start messing 
with this, it could be more problematic!

Thanks,
Vincent

On Monday, March 24, 2014 8:28:30 AM UTC-4, Thomas von Hassel wrote:
>
> Last time i tried to use Console/cake schema (early days 2.x) to mange my 
> databases and their changes, there were some issues with field types. (i'm 
> sorry but i forgot what exactly was the problem)
>
> Are there any pitfalls today ? ... and is this functionality going to make 
> it into 3.0 ?
>
> /thomas
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


I want to prevent users to access other users data. Now I am trying using isAuthorized() function, but not working. Getting '$controller does not implement an isAuthorized() method" error.

2014-03-25 Thread Rahul Dhavale
In app controller added '$this->Auth->authorize = 'Controller';' in before 
filter and added public function isAuthorized() {} function in users 
controller. I don't want to use ACL. 
e.g If logged in users edit profile url is 
http://localhost/abc/users/edit/1 then I want to prevent to acces 
users/edit/2 data. Please help me.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.