Re: How to manipulate cakephp's sessions table with sql

2010-12-01 Thread nightshadex101
Have you had any luck? I'm trying to do the same, and I'n not able to
delete row even with $this->Online->query()...

On Nov 25, 3:08 pm, Ish  wrote:
> Hi Folks,
>
> I am using storing user sessions in database table sessions , and
> trying to manipulate (edit or delete) the sessions table from admin
> panel controls.
>
> // controllers/OnlinesController.php
> // e.g. $id = 'bk86c9argtdlqv7t12g8a0ugf6'
> $this->Online->delete($id); // doesn't work
> //
> // $this->Online->find('all'); // read operations work fine
>
> It's not letting me do that, anybody know's why ?
>
> In my core.php configurations, I have
>
> // config/core.php
> Configure::write('Session.save', 'database');
> Configure::write('Session.model', 'Session');
> Configure::write('Session.table', 'sessions');
> Configure::write('Session.database', 'default');
> Configure::write('Session.cookie', 'CAKEPHP');
> Configure::write('Session.timeout', '144');
> Configure::write('Session.start', true);
> Configure::write('Session.checkAgent', true);
> Configure::write('Security.level', 'medium');
>
> I have separate model Online to handle operations to sessions table.
>
> // models/online.php
> var $useTable = 'sessions';
>
> Any help is greatly appreciated
> - Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Dynamic Menu

2010-08-23 Thread nightshadex101
Hi All,

I'm trying to build a menu system.
I've already created a table in the database, a model (with tree
behavior), and a controller.

The idea is that the menu has 2 levels (it will probably get 3 levels
later), and the following is showed:

-All parent of 1st level pages (controllers)
If I'm on a parent page (ie: a controller)
-All my children/2nd level pages (funcions in that controller)
If I'm on a 2nd level page
-All the other children of my parent (all the other functions in
that controller)

What I'm not getting is how to call this function from an element (to
later insert in the layout) so that I can pass the current page to the
controller function.

This is the db table:

CREATE TABLE IF NOT EXISTS `menus` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` int(10) DEFAULT NULL,
  `lft` int(11) DEFAULT NULL,
  `rght` int(11) DEFAULT NULL,
  `name` varchar(255) COLLATE latin1_general_cs DEFAULT '',
  `location` varchar(255) COLLATE latin1_general_cs DEFAULT '',
  `status` tinyint(1) NOT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)

Model:




Controller:

Menu->field('id', array('location' =>
$location));
$allParents = $this->Menu->find('all', array(
'fields' => array('Menu.id', 'Menu.name', 
'Menu.location'),
'conditions' => array('Menu.parent_id' => null, 
'Menu.status'=>
1)
));
$myParent = $this->Menu->getparentnode($locationId);

if ($myParent) {
$secondLevel = 
$this->Menu->children($myParent['Menu']['id'],
true);
} else {
$secondLevel = $this->Menu->children($locationId, true);
}

$secondLevelFiltered = array();
$i = 0;
foreach ($secondLevel as $children) {
if ($children['Menu']['status'] == 1) {
$secondLevelFiltered[$i]['id'] = 
$children['Menu']['id'];
$secondLevelFiltered[$i]['name'] = 
$children['Menu']['name'];
$secondLevelFiltered[$i]['location'] = 
$children['Menu']
['location'];
$i++;
}
}

$menuTree = array();
$i = 0;
foreach ($allParents as $parent) {
$menuTree[$i] = $parent['Menu'];
if ($myParent) {
if ($myParent['Menu']['id'] == 
$parent['Menu']['id']) {
$menuTree[$i]['children'] = 
$secondLevelFiltered;
}
} else {
if($locationId == $parent['Menu']['id']) {
$menuTree[$i]['children'] = 
$secondLevelFiltered;
}
}
$i++;
}
return($menuTree);
}
}
?>

Could someone give me some orientation on how to procede from here?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en