Delphi For PHP Forums       


Go Back   Delphi-PHP Forums > Delphi4PHP NNTP Newsgroups > embarcadero.public.delphiphp.database
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

embarcadero.public.delphiphp.database This group is for all discussion about databases and using them with Delphi for PHP.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 18th May 2009, 20:57
daniel costa
Guest
 
Posts: n/a
Default Query can't post in D4PHP ?

Hello,

I'm doing a small application to view, insert, edit and delete data from a table. I'm connecting to Mysql and using Query.

I can view and browse the records, but can't do any insert or update. Whenever i try to post, i get this error :

Application raised an exception class ADODB_Exception with message 'mysql error: [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 'LIMIT 1' at line 1] in EXECUTE("SELECT * FROM LIMIT 1")

My code is like this :

qdevedor->append();
qdevedor->Fields['de_cpfcnpj'] = $this->edcpf->text;
qdevedor->Fields['de_nome'] = $this->ednome->text;
qdevedor->post();

This is not working, but i can do the same insert manually, executing a INSERT clause. Can't i do the insert using the query's post method, just in the Delphi for Win32 ?

Thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 18th May 2009, 21:12
daniel costa
Guest
 
Posts: n/a
Default Re: Query can't post in D4PHP ?

Updating : the error is gone after i fill the 'Tablename' property in the query, but the data is not saved. No error, but no post also. Any ideas ?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 19th May 2009, 01:11
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,273
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

i have a problem with query1 edit()
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 19th May 2009, 14:05
daniel costa
Guest
 
Posts: n/a
Default Re: Query can't post in D4PHP ?

> {quote:title=Delphi-PHP Forums wrote:}{quote}
> http://tinyurl.com/qdohae
>


Hello,

Thank you for your reply. I've changed my limits both -1, but now it insert a new record even i calling the edit method ie, it does not
edit , but instead insert a new record...

Any other idea ?

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 19th May 2009, 14:46
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,273
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

Quote:
Originally Posted by daniel costa View Post
>
Any other idea ?
Forget the component and do it the 'old fashioned' way
PHP Code:
        $sql="update `salespeople` set `$column`=$change  where `slsno`=$sls";
        
$result=mysql_query($sql); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 19th May 2009, 15:20
daniel costa
Guest
 
Posts: n/a
Default Re: Query can't post in D4PHP ?

> {quote:title=Delphi-PHP Forums wrote:}{quote}
> daniel costa;13365 Wrote:
> > >

> > Any other idea ?
> >
> >

>
> Forget the component and do it the 'old fashioned' way
>
> PHP code:
> --------------------
>
> $sql="update `salespeople` set `$column`=$change where `slsno`=$sls";
> $result=mysql_query($sql);
>
> --------------------


Well, this way works, i already tried before. But it's a lot of work, as i have more than 20 fields
in the screen... So it's really a bug in the Query component ?

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 29th May 2009, 19:51
daniel costa
Guest
 
Posts: n/a
Default Re: Query can't post in D4PHP ?

So far, i can't edit any record in D4PHP.

The query's post method ALWAYS insert a new record, no matter if it is in insert or edit state ; actually, it can be in browse state and the post method will even insert a new record.

I'm wonder if nobody had this problem yet ?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 2nd June 2009, 13:45
405hp's Avatar
Firebug Fanatic
 
Join Date: Dec 2007
Location: State of Confusion
Posts: 3,273
405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute405hp has a reputation beyond repute
Default

What happens if you use table instead of query?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 3rd June 2009, 17:06
D4PHP Guru
 
Join Date: Nov 2007
Posts: 228
u.masotti is on a distinguished road
Default

Quote:
Originally Posted by daniel costa View Post
So far, i can't edit any record in D4PHP.

The query's post method ALWAYS insert a new record, no matter if it is in insert or edit state ; actually, it can be in browse state and the post method will even insert a new record.

I'm wonder if nobody had this problem yet ?

Thanks
I'm not a MySql fan, but, as presented, seems that database driver inserts a new record because it's not able to build a correct updateable query from your source query.
If your data hasn't an unique key in retrieved data, driver is unable to build an "UPDATE TABLE SET col=value, col1=value1, col2=value2, ... WHERE cond1 AND cond2 AND ..." where each condition is necessary to identify the modified record.
If your query isn't a plain SELECT * FROM TABLE WHERE filtering-condition not all drivers can query DDL to obtain necessary info to build updateable query to process.
__________________
Ciao.
Mimmo.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 10th July 2009, 23:54
dalyla's Avatar
D4PHP User
 
Join Date: Jul 2009
Location: Mexico
Posts: 65
dalyla is on a distinguished road
Default

I also want to make an insert with a query, I've worked with delphi win32, and there I found that using querys in big ones is faster than a table. I think here have to be the same way. But I just find the open(); and not an execute(); function; if this exists why I have to use an old fashioned method or a table. I'm looking for something fast. Also it is ok to know more than one (0 <)
__________________
My world seems to be shinin'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 07:38.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use