Tuesday, September 22, 2015

Classifieds aggregator

Hello,
I'm on a project to build an  portal web of   Classifieds aggregator that will contain two types of ads:
- local ads: added by our users
- Aspirated ads other sites of adds

This is the 1st time that I attack a web project of this magnitude, I would like to know what path to take
For information I have adopted the method of Pascal Roques for my project, but to start development I paddled a bit.

--
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.

Não estou conseguindo usar o plugin CakePtbr para pluralização

Estou usando o cakephp 3.0 e venho tentando utilizar o plugin CakePtbr para corrigir a pluralização e fazer a tradução.

Segui a instrução da documentação do plugin disponivel no github:
1.      Adicionar  a seguinte linha no /config/bootstrap.php Plugin::load("CakePtbr");
2.    Para traduzir as mensagens do core, copie ou faça um link simbólico do arquivo src/Locale/pt_BR/cake.po para sua pasta src/Locale/pt_BR.

Mas a pluralização não esta correta, palavras com o plural terminados em "-oes" tem o sigular gerado com o final "-o" sendo que deveriam ser "-ao". 

Acreditando que o plugin não estava sendo carregado, cheguei nessas configurações:

O erro persistiu... Então troquei o trecho do bootstrap.php
Plugin::load("CakePrbr");
por
Plugin::load(array('CakePtbr'=>array('bootstrap'=>true)));

E agora quando tento fazer bin/cake bake model all surge o seguinte erro:
PHP Fatal error:  Class 'Plugin' not found in ~/plugins/CakePtbr/config/bootstrap.php on line 14

Como solução temporária para corrigir a pluralização estou criando a regra no Inflector, mas também queria utilizar as outras funcionalidades do plugin, então alguém me ajudar?


--
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: get Data from db in index.php

Hi Lakshmana

What version of CakePHP are you using?
Have you looked in the CakePHP book?

Kind regards
John

On Tuesday, 22 September 2015 10:23:50 UTC+3, Lakshmana Katragadda wrote:
hi guys 
  
 i am new to CakePHP.how to get data from db to select box in index.php . and where  should i  place index.php  webroot or src/views 
  
  plz help me. becoz new to cake php

--
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: CAKE 3.0 Tutorials using SQLITE

Thankyou, I'll look into that and learn the migrations system in PART 3 of the Blog tutorial.  My perspective at this point, was as someone new to cake just trying to follow the turorials to see if cakephp was something within my grasp.  The mysql above with instructions to execute the following SQL is part of the tutorial. If I knew SQLITE better, I would have got it converted to SQlite correctly first time!  When I get to PART 3 of the tutorial, I'll play with migrations;
 
Thankyou.
 
On Tuesday, September 22, 2015 at 3:24:50 AM UTC-4, José Lorenzo wrote:
If you use the migrations plugin, there is no need to use the correct SQL for creating the database, as cake will take care of generating everything correctly for you.

Check the sections of the tutorial about using the migrations plugin.

On Monday, September 21, 2015 at 3:38:11 AM UTC+2, jacmgr wrote:
I ahev successfully installed cake and Mysql and completed the tutorials for bookmarks and blog.  Now I want to use SQlite.  I can successfully connect to my sqlite database.  I tried using the same Mysql statements found on page 13 of the cookbook that were successful with Mysql; however,  I got several errors and the tables were not created.   Does any one have a export of the sql statements that will work in SQlite.  I really would like to use SQlite.  Any help would be greatly appreciated. These are the errors and not sure how to modify so that they are consistent with cake:

--
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: New CakePHP ORM to CakePHP 2.x

It depends. The ORM can be installed as a standalone library already, what kind of integration are you looking after?

On Tuesday, September 22, 2015 at 9:23:50 AM UTC+2, Sulian Lanteri wrote:
Hello

Before migrate a big application in CakePHP3, I want first use the new ORM in this CakePHP 2.6 application, any idea how to do that (and/or a good example) ?

Sulian

--
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: Collection::reduce versus doing a foreach

Maybe this is what you are looking for:

collection($items)
    // I only care about elements having the id = a or id = b
    ->filter(function ($value, $key) use ($array) {
        return isset($array[$value['id']]); // If the key is in the array, the it should be kept in the collection
    })

    /// Let's now index the collection by the id
    ->groupBy('id')

    // Finally, let's reduce the collection to list of strings per key

    ->reduce(function ($result, $value) {
        return $result . ', ' . $value['title'];
    }, '')

I have created this gist for better readability: https://gist.github.com/lorenzo/9198544013a9ca067689

Hope this helps!

On Monday, September 14, 2015 at 10:08:55 AM UTC+2, Walter Vos wrote:
Hi!

I'm having trouble wrapping my head around Collection::reduce. Actually, it feels like I understand how it's supposed to work, but in reality it seems to work differently. I have a collection of entities, from which I'm trying to concat a number of string, based on another array (could probably also be an array, I don't think it would matter much). The array has an ID, the collection has that ID as a foreign ID. I loop through the array, and then in each loop I loop through the collection to find the entities which have a foreign ID matching the ID from the array. Implementing this with Collection::reduce gives a wildly different result from doing it with two foreach() loops. Anyway, here's the code:

public function reducetest() {
    $this->render('test');

    $groupby = ['a' => 1, 'b' => 2];
    $array = [
        array('id' => 'b', 'title' => 'array_tag_1'),
        array('id' => 'a', 'title' => 'array_tag_2'),
        array('id' => 'b', 'title' => 'array_tag_3'),
        array('id' => 'a', 'title' => 'array_tag_4'),
        array('id' => 'a', 'title' => 'array_tag_5')
    ];
    $array_result = array();
    foreach ($groupby as $key => $value) {
        $array_result[$key] = '';
        foreach ($array as $item) {
            if ($key === $item['id']) {
                // debug($array_result[$key] . $item['title'] . ", \n");
                $array_result[$key] .= $item['title'] . ', ';
            }
        }
        $array_result[$key] = trim($array_result[$key], ', ');
    }
    debug($array_result);

    $collection = new Collection([
        array('id' => 'b', 'title' => 'collection_tag_1'),
        array('id' => 'a', 'title' => 'collection_tag_2'),
        array('id' => 'b', 'title' => 'collection_tag_3'),
        array('id' => 'a', 'title' => 'collection_tag_4'),
        array('id' => 'a', 'title' => 'collection_tag_5')]
    );
    $collection_result = array();
    foreach ($groupby as $key => $value) {
        $collection_result[$key] = $collection->reduce(function ($string, $item) use ($key) {
            if ($key === $item['id']) {
                // debug($string . $item['title'] . ", \n");
                return $string . $item['title'] . ', ';
            }
        }, '');
        $collection_result[$key] = trim($collection_result[$key], ', ');
    }
    debug($collection_result);
}

The code with the two foreach() loops produces this result, as expected:

[
    'a' => 'array_tag_2, array_tag_4, array_tag_5',
    'b' => 'array_tag_1, array_tag_3'
]

The code that uses the reduce function gives this result, incomprehensibly to me:

[
'a' => 'collection_tag_4, collection_tag_5',
'b' => ''
]

Who can explain to me what I'm not understanding here?

--
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: CAKE 3.0 Tutorials using SQLITE

If you use the migrations plugin, there is no need to use the correct SQL for creating the database, as cake will take care of generating everything correctly for you.

Check the sections of the tutorial about using the migrations plugin.

On Monday, September 21, 2015 at 3:38:11 AM UTC+2, jacmgr wrote:
I ahev successfully installed cake and Mysql and completed the tutorials for bookmarks and blog.  Now I want to use SQlite.  I can successfully connect to my sqlite database.  I tried using the same Mysql statements found on page 13 of the cookbook that were successful with Mysql; however,  I got several errors and the tables were not created.   Does any one have a export of the sql statements that will work in SQlite.  I really would like to use SQlite.  Any help would be greatly appreciated. These are the errors and not sure how to modify so that they are consistent with cake:

CREATE TABLE users (  id INT AUTO_INCREMENT PRIMARY KEY,  email VARCHAR(255) NOT NULL,  password VARCHAR(255) NOT NULL,  created DATETIME,  modified DATETIME  )

Query executed OK, 0 rows affected. (0.006 s)


CREATE TABLE bookmarks (  id INT AUTO_INCREMENT PRIMARY KEY,  user_id INT NOT NULL,  title VARCHAR(50),  description TEXT,  url TEXT,  created DATETIME,  modified DATETIME,  FOREIGN KEY user_key (user_id) REFERENCES users(id)  )

Error in query (1): near "user_key": syntax error


CREATE TABLE tags (  id INT AUTO_INCREMENT PRIMARY KEY,  title VARCHAR(255),  created DATETIME,  modified DATETIME,  UNIQUE KEY (title)  )

Error in query (1): near "KEY": syntax error



CREATE TABLE bookmarks_tags (  bookmark_id INT NOT NULL,  tag_id INT NOT NULL,  PRIMARY KEY (bookmark_id, tag_id),  FOREIGN KEY tag_key(tag_id) REFERENCES tags(id),  FOREIGN KEY bookmark_key(bookmark_id) REFERENCES bookmarks(id)  )

Error in query (1): near "tag_key": syntax error


* also does not seem to allow 2 primary keys.



--
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.