Sunday, October 18, 2015

cakephp3 and lots of inserts

Hello,

I have an EventTable which hasMany Images. Each time I insert an event I loop through a folder for jpg images. In each loop I d

$image = $this->Image->newEntity(['code' => $code]);
array_push
($images, $image);



Then outside loop I do

$events->images = $images;


Considering I have more than 10.000 images is this an ideal approach? Database log shows it takes about 1 minute for more than 10.000 inserts while the whole controller actions takes more than 2 minutes ( I guess it's the newEntity call?)
Can I do something else to speed the process?

Thanks

--
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+unsubscribe@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 3 how to limit number on items in contain per item not globally

I have articles connected with categories. I would like to get at most two articles for each category. There is many to one connection. So I use the following.

$query = $categories->find()->contain([      'Articles' => [          'queryBuilder' => function ($q) {              return $q->limit(2);           }      ]  ]);

Unfortunately the limit 2 seams to be global. I get 2 articles from the first category an then no articles connected with other categories.

How can I set the limit per item and not globally.

--
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+unsubscribe@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.

Thursday, October 15, 2015

How I can use Paginator at App\View\Cell?

Who know? How I can use Paginator at App\View\Cell?

--
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+unsubscribe@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.

Advice on menu setup

Hi

I'm new to cakephp

I'm using version 3

I've been working through an existing site i have built and trying to replicate it with cakephp

I did a lot very quickly which is great but the menu is tricky

Since this is a navigation bar at the top of every page i thought i might use an element

The problem there seems to be getting the data into it from the database

I've read the manual quite a bit and based on that i thought maybe creating a model and controller for the menu would be the best way to go

Then i could call the menu controller from the article controller and get the menu data that way

It looks like i can pass the data into the menu element from there?

But then where do i put the code that actually takes the data and generates the menu?

I've looked at various tutorials but it's not made things clearer

I'd really appreciate some advice here folks.

Cheers.




--
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+unsubscribe@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: How do I get Cake 3.1 to reply to an AJAX request without requiring a layout .ctp file?

Okay, problem solved.
The _ext is not needed, removed it.
added the line:
$this->RequestHandler->renderAs($this, 'json');
       
Now renders as a JsonView and the _Serialize is automatically detected and no template file required.

Regards,
--Kevin

On Wednesday, October 14, 2015 at 2:02:24 PM UTC+7, heavyKevy wrote:
I have gone through the documentation, which is a bit too vague, and tried many things, but I still am getting an error that the template file is missing.

I had this working sending back a json response in 3.0 using ext='json', yet after updating to 3.1 it is broken. 

I checked the migration guide and tried changing ext  to _ext, setting up the Routes with:
Router::extensions(['json']);

in the controller method I am using the _serialize key which is supposed to render without the template:
$this->set('_serialize', ['salesPeople']);

The JsonView class does not appear to be loading and I don't see in the documentation where I am supposed to set it.
The documentation says ' you can automatically leverage the new view classes' By enabling RequestHandlerComponent in your application, and enabling support for the json and or xml extensions, but I have enabled it in the Initialize method of the controller and enabled the 'json' extension as mentioned earlier and it is still not working.

Here is the method in question:
public function getSalesPeopleSelectList() {
        $this->request->accepts('json'); // No direct access via browser URL
        $dealerId = $this->request->params['pass'][0];
        $this->RequestHandler->renderAs($this, 'ajax');
        //$this->viewClass = 'Json';
        $this->loadModel('SalesPeople');
        $salesPeople = $this->Purchases->SalesPeople->find('list')->where(['is_active'=>'1','user_id'=>$dealerId]);  //for salespeople options for autocomplete
        $this->set(compact('salesPeople'));
        $this->set('_serialize', ['salesPeople']);
    }


When I enable the _ext = json I get the following error:

2015-10-14 06:57:36 Error: [Cake\Controller\Exception\MissingActionException] Action PurchasesController::getSalesPeopleSelectList.json() could not be found, or is not accessible.
Exception Attributes: array (
  'controller' => 'PurchasesController',
  'action' => 'getSalesPeopleSelectList.json',
  'prefix' => '',
  'plugin' => NULL,
)
Request URL: /Subaru/purchases/get-sales-people-select-list.json/47
Stack Trace:
#0 C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(114): Cake\Controller\Controller->invokeAction()
#1 C:\WebServer\cake\subaru\vendor\cakephp\cakephp\src\Routing\Dispatcher.php(87): Cake\Routing\Dispatcher->_invoke(Object(App\Controller\PurchasesController))
#2 C:\WebServer\webdocs\Subaru\index.php(42): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#3 {main}

What have I missed?

--
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+unsubscribe@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: Looking for a CakePHP Tutor with some help with MVC project

Corey,

I am be willing to help.
Let me know what help/assistance you need.

Regards,
--Kevin

On Thursday, October 15, 2015 at 3:45:06 AM UTC+7, LSRX4EVER wrote:
Hello,

I am currently working on an internship web application that is utilizing CakePHP. Currently I have a very large mysql database schema and have been working slowly on developing and learning CakePHP. I am interested in finding a developer who is willing to freely devote some of their time in educating/assistanting me along with my project. I have dove through tons of documentation, forums and examples and it would be great to bounce a few questions or ideas with an educated cakephp developer. Please message me or email me if someone is interested.

Thanks,
Corey

--
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+unsubscribe@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.

Wednesday, October 14, 2015

Cakephp 3 How to update multiple row data in a single query

Hi all,

I have multiple rows in database.

I need to collect all the rows based on certain condition and change the value of particular column by removing a word from the column's value.

How it could be done with with cakePHP 3?


--
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+unsubscribe@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.