Re: Problem with MySQL query

2008-09-11 Thread krzysztofor

I wasn't writting it by myself, but i have to fix this bug.
I don't have OptionsController, but propably PagesController will be
helpful, because the problem is when i'm on the site with page list.
There is everything okey, but when I click on existing page to edit
it, this warning appears, and all forms are empty, because they can't
be taken from database (wrong query).
The strangest thing is that it works localy...

 controllers/pages-controller.php


registerSubmenuItem('Click here to create a new page in 
the
top level menu', 'pages/add');
}
/**
 * List action
 *
 */
function index() {
$this->Language->recursive = -1;
$this->set('languages', $this->Language->find('all'));
$this->constructSubmenu();
//$this->Page->recursive = 0;
//$this->set('pages', $this->paginate());
$this->loadModel('Extension');

$tree = $this->Menu->getStructuredTree(1);
//print_r($tree);
//print_r($tree);
$extensions = $this->Extension->loadAll();
$this->set('extensions', $extensions);

$this->set('tree', $tree);

//print_r($options);
//echo '';
//print_r($tree);
}

/**
 * Edit a page
 *
 * @param int $id
 */
function edit($id = null) {

if (!$id && empty($this->data)) {

$this->flash(__('Invalid Page', true), 
array('action'=>'index'),
'error');
exit();
}

// link fugu libraries
$this->fuguLink('media,windows,tabs,page,editor');

// load Extension model
$this->loadModel('Extension');

if (!empty($this->data)) {
if ($this->Page->verifyUri($this->data)) {
// save page
if ($this->Page->save($this->data)) {

if (!empty($_POST['extension'])) {
// save extension
if 
(empty($this->data['Extension'])) $this->data['Extension'] =
null;
$extension = 
$_POST['extension'];
$extension_obj = 
$this->Extension->init($extension);
$extension_obj->handle($id, 
$this->data['Extension'],
false);
}

$name = $this->data['Page']['name'];
$this->flash(__('The page "'.$name.'" 
has been saved.', true),
array('action'=>'index'), 'success');

exit();
} else {
}
} else {
$this->Session->setFlash('The uri you specified
already exists, please try another one', null);
}
}
if (empty($this->data)) {
$this->data = $this->Page->read(null, $id);
$this->set('data', $this->data);
if ($this->data==null) {
$this->flash(__('Invalid page', true), 
array('action'=>'index'),
'error', __('That page was probably removed', true));

}

}



// attach the extension object and extract data
//print_r($_POST);
if (!empty($_POST['extension'])) {
$extension_name = $_POST['extension'];
} else {
$extension_name = 
$this->data['Option']['extension_name'];
$extension_args = 
$this->data['Option']['extension_args'];
}
// print_r($this->data);
// echo $extension_name;
$extension = $this->Extension->load($extension_name);
$extension_obj = $this->Extension->init($extension_name);
$ext_data = $extension_obj->fetch($id, $extension_args);
$extension['data'] = $ext_data;
//print_r($extension['data']);
if (!empty($this->data['Extension'])) $extension['data'] = 
$this-
>data['Extension'];
//print_r($extension['data']);
$this->set('extension', $extension);

// register tabs
$this->registerSidebarTab('General', 'tab_general',
'GeneralScreen');
$this->registerSidebarTab('Meta', 'tab_meta', 'MetaScreen');
$this->registerSidebarTab($extension['cfg']['

Re: Problem with MySQL query

2008-09-11 Thread krzysztofor

but i don't know where it is genereted :/

where can it be?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Problem with MySQL query

2008-09-10 Thread krzysztofor

Hello everybody. I'm begginer with CakePHP. The MySQL query is
genereting in a wrong way:

Query:
SELECT `Option`.`id`, `Option`.`menu_id`, `Option`.`parent_id`,
`Option`.`page_id`, `Option`.`order`, `Option`.`extension_name`,
`Option`.`extension_args`, `Option`.`menu` FROM `fk3_options` AS
`Option` WHERE `Option`.`pageid` = 41 LIMIT 1

The problem is in the 'WHERE clause'. The record 'pageid' doesn't
exist, instead of it should be 'page_id'.

Warning (512): SQL Error: 1054: Unknown column 'Option.pageid' in
'where clause' [ROOT/system/cake/libs/model/datasources/
dbo_source.php, line 440]

There is no problem on localhost, but it is on the external server :(.
Please help me if you can.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---