Re: Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
On Wednesday, 9 May 2012 19:13:58 UTC+2, sup...@deep-coding.net wrote:
Hi,
I am getting this Error:
Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near
'erstelleAuswahl' at line 1
When I am trying to retrieve some data of my database.
Here is my function in KundenController.php
public function erstelleAuswahl() {
$this->Kunde->recursive = -1;
$fields = array('Kunde.id', 'Kunde.anrede_id',
'Kunde.vorname', 'Kunde.nachname', 'Kunde.name');
$conditions = array('Kunde.gruppen_id' => $this->Auth-
>user('gruppen_id'));
$kundenliste = $this->Kunde->find('all', array('fields' =>
$fields, 'conditions' => $conditions));
foreach($kundenliste as $kunde) {
if($kunde['Kunde']['anrede_id'] == 'FA') {
$kunden[$kunde['Kunde']['id']] = $kunde['Kunde']
['name'];
} else {
$kunden[$kunde['Kunde']['id']] = $kunde['Kunde']
['nachname'].' '.$kunde['Kunde']['vorname'];
}
}
return $kunden;
//print_r($kunden);
}
And if I am calling this function to get the array, I always get the
error.
I have debugged the SQL query, here it is:
SELECT `Kunde`.`id`, `Kunde`.`anrede_id`, `Kunde`.`vorname`,
`Kunde`.`nachname`, `Kunde`.`name` FROM `mweb`.`kunden` AS `Kunde`
WHERE `Kunde`.`gruppen_id` = 1
If I run this query in phpMyAdmin I get my data.
So I have no Idea, what's the problem.
"... right syntax to use near 'erstelleAuswahl'"
You are calling a method named "erstelleAuswahl" which doesn't exist. which probably means your model filename is misnamed.
check the class of the object you're calling to confirm (it'll be AppModel)
check that your model file follows conventions.
AD
-- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home