Changing database table name
3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 24, 2012 (RSS)
Hello,
I have a Listing Detail page that displays the advertiser contact details. These contact details are currently being pulled from a table called "homepages".
I would like to change this so that the data comes from the "accounts" table.
I have setup all the fields in the "accounts" table and tried doing a search and replace in the Listing Detail file (searching for "homepages" and replacing with "accounts").
Unfortunately, this doesn't seem to have worked but I don't understand why it hasn't.
I have the following at the top of listingDetail:
So I have changed this to:
Then each of my fields have been updated from:
to:
Can someone please advise what else I need to do?
Thank you for your help.
Regards,
Greg
I have a Listing Detail page that displays the advertiser contact details. These contact details are currently being pulled from a table called "homepages".
I would like to change this so that the data comes from the "accounts" table.
I have setup all the fields in the "accounts" table and tried doing a search and replace in the Listing Detail file (searching for "homepages" and replacing with "accounts").
Unfortunately, this doesn't seem to have worked but I don't understand why it hasn't.
I have the following at the top of listingDetail:
// load listings
list($listingsRecordRecords, $listingsRecordDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'homepages',
'where' => "num = '".intval(@$_REQUEST['productNum'])."'",
'limit' => '1',
'allowSearch' => false,
));
So I have changed this to:
// load listings
list($listingsRecordRecords, $listingsRecordDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'accounts',
'where' => "num = '".intval(@$_REQUEST['productNum'])."'",
'limit' => '1',
'allowSearch' => false,
));
Then each of my fields have been updated from:
<?php echo $listingsRecord['homepages.contact_name'] ?>
to:
<?php echo $listingsRecord['accounts.contact_name'] ?>
Can someone please advise what else I need to do?
Thank you for your help.
Regards,
Greg
Re: [gversion] Changing database table name
By Jason - February 23, 2012
Hi Greg,
'joinTable' => 'accounts',
is a special case in the getRecords function. What it attempts to do is to match the 'createdByUserNum' field of your first table (ie listings) with the num of the accounts table. In other words, it retrieves the user account of the user that created the record. If this is what you are looking for, the functionality actually comes by default without using the joinTable option. You can access any accounts field by using the createdBy. prefix.
For example:
Hope this helps
'joinTable' => 'accounts',
is a special case in the getRecords function. What it attempts to do is to match the 'createdByUserNum' field of your first table (ie listings) with the num of the accounts table. In other words, it retrieves the user account of the user that created the record. If this is what you are looking for, the functionality actually comes by default without using the joinTable option. You can access any accounts field by using the createdBy. prefix.
For example:
<?php echo $listingsRecord['createdBy.contact_name'] ?>
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Changing database table name
Hi Jason,
That's exactly what I needed to know!
Thank you very much.
Regards,
Greg
That's exactly what I needed to know!
Thank you very much.
Regards,
Greg