Joomla! Discussion Forums



It is currently Wed Nov 25, 2009 12:25 am (All times are UTC )

 




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Database functions
Posted: Mon Dec 10, 2007 9:22 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Sep 19, 2006 6:18 pm
Posts: 32
Hi,

I am currently trying to create a component that wont use incremental ids.
Is it possible to use the typical Store, bind and load functions of the database?

I am having quite troubles in using those functions. Should i have to make something customizable for varchar keys and non incremental?


Imagine my table contains two fields... code varchar(50) and description varchar (100)

How could i make the save function of my component?



Cheers :)


Top
  E-mail  
 
 Post subject: Re: Database functions
Posted: Mon Dec 10, 2007 9:37 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Fri Aug 12, 2005 2:45 am
Posts: 1578
Location: Toowoomba, Australia
No, you won't be able to use the typical store method.  You will have to write your own to update the data.  Assume you have some sort of index on the table you could use a REPLACE INTO statement rather than INSERT and UPDATE's.  Hope this helps.

_________________
Andrew Eddie - Tweet @AndrewEddie
<><
http://www.theartofjoomla.com
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.


Top
   
 
 Post subject: Re: Database functions
Posted: Mon Dec 10, 2007 9:41 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Sep 19, 2006 6:18 pm
Posts: 32
REPLACE INTO?? Can you give an example?

What about BIND and CHECK methods?

Regards


Top
  E-mail  
 
 Post subject: Re: Database functions
Posted: Mon Dec 10, 2007 10:25 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Fri Aug 12, 2005 2:45 am
Posts: 1578
Location: Toowoomba, Australia
Ok, bind and check will still work fine.  You just need to override the store method.  Use whatever methods you are comfortable with but I was just suggesting to research REPLACE INTO (http://dev.mysql.com/doc/refman/5.0/en/replace.html) as I find this useful for database table that do not have your regular single primary key.

If your "code" field is a primary key but not an auto-increment then it's probably still a good case for using REPLACE into.  Go as far as you can and then post the code for your Table class and I'll see if I can help more (will be out all day today though so will be tomorrow before I can reply).

_________________
Andrew Eddie - Tweet @AndrewEddie
<><
http://www.theartofjoomla.com
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.


Top
   
 
 Post subject: Re: Database functions
Posted: Mon Dec 10, 2007 10:33 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Sep 19, 2006 6:18 pm
Posts: 32
Ok so i have my $row variable populated... What can i do now?

Instead of doing $row->store() what about now?

Regards


Top
  E-mail  
 
 Post subject: Re: Database functions
Posted: Mon Dec 10, 2007 10:46 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Fri Aug 12, 2005 2:45 am
Posts: 1578
Location: Toowoomba, Australia
Can you post the code of your Table class please.

_________________
Andrew Eddie - Tweet @AndrewEddie
<><
http://www.theartofjoomla.com
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.


Top
   
 
 Post subject: Re: Database functions
Posted: Mon Dec 10, 2007 11:31 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Sep 19, 2006 6:18 pm
Posts: 32
class tabela extends mosDBTable{


  var key = null;
  var description = null;

  function mosTabela (&$db){
    $this->mosDBTable('#__tabela', 'key', $db);
  }
}


Top
  E-mail  
 
 Post subject: Re: Database functions
Posted: Tue Dec 11, 2007 8:53 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Sep 19, 2006 6:18 pm
Posts: 32
No one can help on this issue?
Please


Regards


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group