Monday, November 4, 2013

Re: hasOne load time x4


HI Aurelian,
There is not any problem when you use containable, its good to use that feature.

Coming to the problem part,
1. First thing what i guess is that you have not set the index properly for tables that are related so that you are also delaying the result in the second association ($hasMany)
2. Second thing is that if u have A $hasOne B association then cake expects one-one relationship with respect to the primaryKey and foreignKey as it find violation of
referential integrity it causes slow record fetching.

if you have any doubt you are welcome to ask.


On Friday, November 1, 2013 9:42:55 PM UTC+5:30, Aurelian Apostol wrote:
I am using two tables items and products, item hasOne product.
When making a containable pagination on Item it loads 1200 rows in 13s, when moving Product in hasMany it loads in 3,2s. With no other changes on the models or any other place as that matters.

Any ideas?

--
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/groups/opt_out.

Sunday, November 3, 2013

Re: hasOne load time x4

Please export here your db schema. 

On Friday, November 1, 2013 11:12:55 PM UTC+7, Aurelian Apostol wrote:
I am using two tables items and products, item hasOne product.
When making a containable pagination on Item it loads 1200 rows in 13s, when moving Product in hasMany it loads in 3,2s. With no other changes on the models or any other place as that matters.

Any ideas?

--
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/groups/opt_out.

Saturday, November 2, 2013

Croogo, multiple sites and user permissions

I am thinking about using Croogo for a new project.
I need to create multiple sites (multiple domains) and need each site to
look independent, so they have their own pages, content, and editors
(users). Each editor should only see their site and content from the
admin side.

Anyone have some suggestions on plugins that I can use to get started.  
I may have to make some changes, but if I can get a head start, that
would be great.

Thanks,
Bill


View this message in context: Croogo, multiple sites and user permissions
Sent from the CakePHP mailing list archive at Nabble.com.

--
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/groups/opt_out.

Re: Cookie Helper

A "read only" version - similar to SessionHelper - sure wouldn't be bad practice
The danger here is again, that people use it to write from the view layer. Also, in most cases it is totally sufficient and maybe even better to read
the data in the controller and then act on it accordingly (pass down the data needed to the view).

mark


Am Samstag, 2. November 2013 14:31:56 UTC+1 schrieb mercury12:
I know that there exists no Cookie Helper, but I need to reach cookies from my view files ?
One can reach cookies from controller and pass cookie data to view files. But it is cumbersome for each action.

Is reaching cookies from the view files or custom helpers is a bad practice ? Does it conflict with MVC pattern ? I'm sure that CookieHelper isn't added on purpose. But I need to know why ? And what do you do for cookies-view relation ? Do you pass from controller ?



--
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/groups/opt_out.

Cookie Helper

I know that there exists no Cookie Helper, but I need to reach cookies from my view files ?
One can reach cookies from controller and pass cookie data to view files. But it is cumbersome for each action.

Is reaching cookies from the view files or custom helpers is a bad practice ? Does it conflict with MVC pattern ? I'm sure that CookieHelper isn't added on purpose. But I need to know why ? And what do you do for cookies-view relation ? Do you pass from controller ?



--
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/groups/opt_out.

Friday, November 1, 2013

hasOne load time x4

I am using two tables items and products, item hasOne product.
When making a containable pagination on Item it loads 1200 rows in 13s, when moving Product in hasMany it loads in 3,2s. With no other changes on the models or any other place as that matters.

Any ideas?

--
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/groups/opt_out.

Re: ShellDispatcher help

I'd guess you're using php 4 https://github.com/cakephp/cakephp/blob/master/lib/Cake/Console/ShellDispatcher.php#L32

On Friday, 1 November 2013 02:37:55 UTC+1, Jared Testa wrote:
I'm new to CakePHP.  My first install was 2.4.1, right before .2 came out.  I tried using Shell in .1 and got an error.  I also noticed the update the same time, so I went ahead and updated to .2.

I'm getting a syntax error when trying to run Console/cake.  

<b>Parse error</b>:  syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/home/content/15/10888415/html/flight/lib/Cake/Console/ShellDispatcher.php</b> on line <b>33</b><br />

Yes, a simple syntax error.  I HAVE NOT modified anything in the LIB directory.  Here is my entire ShellDispatcher.php file:

<?php
/**
 * ShellDispatcher file
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         CakePHP(tm) v 2.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

/**
 * Shell dispatcher handles dispatching cli commands.
 *
 * @package       Cake.Console
 */
class ShellDispatcher {

/**
 * Contains command switches parsed from the command line.
 *
 * @var array
 */
public $params = array();

/**
 * Contains arguments parsed from the command line.
 *
 * @var array
 */
public $args = array();

/**
 * Constructor
 *
 * The execution of the script is stopped after dispatching the request with
 * a status code of either 0 or 1 according to the result of the dispatch.
 *
 * @param array $args the argv from PHP
 * @param boolean $bootstrap Should the environment be bootstrapped.
 */
public function __construct($args = array(), $bootstrap = true) {
set_time_limit(0);
$this->parseParams($args);

if ($bootstrap) {
$this->_initConstants();
$this->_initEnvironment();
}
}

/**
 * Run the dispatcher
 *
 * @param array $argv The argv from PHP
 * @return void
 */
public static function run($argv) {
$dispatcher = new ShellDispatcher($argv);
return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
}

/**
 * Defines core configuration.
 *
 * @return void
 */
protected function _initConstants() {
if (function_exists('ini_set')) {
ini_set('html_errors', false);
ini_set('implicit_flush', true);
ini_set('max_execution_time', 0);
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('DS', DIRECTORY_SEPARATOR);
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
define('CAKEPHP_SHELL', true);
if (!defined('CORE_PATH')) {
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
}

/**
 * Defines current working environment.
 *
 * @return void
 * @throws CakeException
 */
protected function _initEnvironment() {
if (!$this->_bootstrap()) {
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
throw new CakeException($message);
}

if (!isset($this->args[0]) || !isset($this->params['working'])) {
$message = "This file has been loaded incorrectly and cannot continue.\n" .
"Please make sure that " . DS . 'lib' . DS . 'Cake' . DS . "Console is in your system path,\n" .
"and check the cookbook for the correct usage of this command.\n" .
throw new CakeException($message);
}

$this->shiftArgs();
}

/**
 * Initializes the environment and loads the CakePHP core.
 *
 * @return boolean Success.
 */
protected function _bootstrap() {
if (!defined('ROOT')) {
define('ROOT', $this->params['root']);
}
if (!defined('APP_DIR')) {
define('APP_DIR', $this->params['app']);
}
if (!defined('APP')) {
define('APP', $this->params['working'] . DS);
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', APP . $this->params['webroot'] . DS);
}
if (!defined('TMP') && !is_dir(APP . 'tmp')) {
define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'tmp' . DS);
}
$boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 'bootstrap.php');
require CORE_PATH . 'Cake' . DS . 'bootstrap.php';

if (!file_exists(APP . 'Config' . DS . 'core.php')) {
include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'Config' . DS . 'core.php';
App::build();
}

$this->setErrorHandlers();

if (!defined('FULL_BASE_URL')) {
$url = Configure::read('App.fullBaseUrl');
define('FULL_BASE_URL', $url ? $url : 'http://localhost');
Configure::write('App.fullBaseUrl', FULL_BASE_URL);
}

return true;
}

/**
 * Set the error/exception handlers for the console
 * based on the `Error.consoleHandler`, and `Exception.consoleHandler` values
 * if they are set. If they are not set, the default ConsoleErrorHandler will be
 * used.
 *
 * @return void
 */
public function setErrorHandlers() {
App::uses('ConsoleErrorHandler', 'Console');
$error = Configure::read('Error');
$exception = Configure::read('Exception');

$errorHandler = new ConsoleErrorHandler();
if (empty($error['consoleHandler'])) {
$error['consoleHandler'] = array($errorHandler, 'handleError');
Configure::write('Error', $error);
}
if (empty($exception['consoleHandler'])) {
$exception['consoleHandler'] = array($errorHandler, 'handleException');
Configure::write('Exception', $exception);
}
set_exception_handler($exception['consoleHandler']);
set_error_handler($error['consoleHandler'], Configure::read('Error.level'));
}

/**
 * Dispatches a CLI request
 *
 * @return boolean
 * @throws MissingShellMethodException
 */
public function dispatch() {
$shell = $this->shiftArgs();

if (!$shell) {
$this->help();
return false;
}
if (in_array($shell, array('help', '--help', '-h'))) {
$this->help();
return true;
}

$Shell = $this->_getShell($shell);

$command = null;
if (isset($this->args[0])) {
$command = $this->args[0];
}

if ($Shell instanceof Shell) {
$Shell->initialize();
return $Shell->runCommand($command, $this->args);
}
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
$added = in_array($command, $methods);
$private = $command[0] === '_' && method_exists($Shell, $command);

if (!$private) {
if ($added) {
$this->shiftArgs();
$Shell->startup();
return $Shell->{$command}();
}
if (method_exists($Shell, 'main')) {
$Shell->startup();
return $Shell->main();
}
}

throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command));
}

/**
 * Get shell to use, either plugin shell or application shell
 *
 * All paths in the loaded shell paths are searched.
 *
 * @param string $shell Optionally the name of a plugin
 * @return mixed An object
 * @throws MissingShellException when errors are encountered.
 */
protected function _getShell($shell) {
list($plugin, $shell) = pluginSplit($shell, true);

$plugin = Inflector::camelize($plugin);
$class = Inflector::camelize($shell) . 'Shell';

App::uses('Shell', 'Console');
App::uses('AppShell', 'Console/Command');
App::uses($class, $plugin . 'Console/Command');

if (!class_exists($class)) {
throw new MissingShellException(array(
'class' => $class
));
}
$Shell = new $class();
$Shell->plugin = trim($plugin, '.');
return $Shell;
}

/**
 * Parses command line options and extracts the directory paths from $params
 *
 * @param array $args Parameters to parse
 * @return void
 */
public function parseParams($args) {
$this->_parsePaths($args);

$defaults = array(
'app' => 'app',
'root' => dirname(dirname(dirname(dirname(__FILE__)))),
'working' => null,
'webroot' => 'webroot'
);
$params = array_merge($defaults, array_intersect_key($this->params, $defaults));
$isWin = false;
foreach ($defaults as $default => $value) {
if (strpos($params[$default], '\\') !== false) {
$isWin = true;
break;
}
}
$params = str_replace('\\', '/', $params);

if (isset($params['working'])) {
$params['working'] = trim($params['working']);
}

if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0][0] !== '.')) {
if ($params['working'][0] === '.') {
$params['working'] = realpath($params['working']);
}
if (empty($this->params['app']) && $params['working'] != $params['root']) {
$params['root'] = dirname($params['working']);
$params['app'] = basename($params['working']);
} else {
$params['root'] = $params['working'];
}
}

if ($params['app'][0] === '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
$params['root'] = dirname($params['app']);
} elseif (strpos($params['app'], '/')) {
$params['root'] .= '/' . dirname($params['app']);
}

$params['app'] = basename($params['app']);
$params['working'] = rtrim($params['root'], '/');
if (!$isWin || !preg_match('/^[A-Z]:$/i', $params['app'])) {
$params['working'] .= '/' . $params['app'];
}

if (!empty($matches[0]) || !empty($isWin)) {
$params = str_replace('/', '\\', $params);
}

$this->params = array_merge($this->params, $params);
}

/**
 * Parses out the paths from from the argv
 *
 * @param array $args
 * @return void
 */
protected function _parsePaths($args) {
$parsed = array();
$keys = array('-working', '--working', '-app', '--app', '-root', '--root');
foreach ($keys as $key) {
while (($index = array_search($key, $args)) !== false) {
$keyname = str_replace('-', '', $key);
$valueIndex = $index + 1;
$parsed[$keyname] = $args[$valueIndex];
array_splice($args, $index, 2);
}
}
$this->args = $args;
$this->params = $parsed;
}

/**
 * Removes first argument and shifts other arguments up
 *
 * @return mixed Null if there are no arguments otherwise the shifted argument
 */
public function shiftArgs() {
return array_shift($this->args);
}

/**
 * Shows console help. Performs an internal dispatch to the CommandList Shell
 *
 * @return void
 */
public function help() {
$this->args = array_merge(array('command_list'), $this->args);
$this->dispatch();
}

/**
 * Stop execution of the current script
 *
 * @param integer|string $status see http://php.net/exit for values
 * @return void
 */
protected function _stop($status = 0) {
exit($status);
}

}

>?


Line 33 is actually blank.  Line 32 looks to be complete.  I for the life of me can't figure out what's causing the syntax error, and am perplexed as it came that way.  Has no one else had this problem?

Thanks in advance 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+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/groups/opt_out.