Custom DB Table Access

Custom DB Table Access

Postby octobert on Thu Jul 23, 2009 10:21 am

Hi...I am sure this is already someplace (and probably in an obvious place) but I haven't been able to find information on this topic. I have a custom table in my DB and it really has nothing to do with my blog except that I am showing the information within my blog.

Are their instructions somewhere on how to use the database classes? I was able to get want I want working in straight PHP, but once I include it in my template, it gets an error and I am guessing this is because I need to use LifeType's classes. I honestly don't know where to begin here.

Thanks.
octobert
 
Posts: 3
Joined: Thu Jul 23, 2009 10:15 am
LifeType Version: 1.2.8

Re: Custom DB Table Access

Postby jondaley on Fri Jul 24, 2009 11:10 am

If you turn on "allow php in the templates" (and only have trusted users who have access to the templates) you can do straight php to access the mysql database, and LifeType won't care at all.

What code are you using, and what is your error?
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Custom DB Table Access

Postby octobert on Thu Jul 30, 2009 9:08 am

Jon,
I am the only one who has access to the templates, so this solutions works...Thank you very much. I was beginning to pull my hair out.

The code was just a straight forward database connection that returned some rows (se below) and it was returning an unrecognized smarty class error (or something like that). I don't know smarty at all...I've just been hacking things as I go along, but, obviously, got stuck here. I should learn smarty when I get a chance.

$con = mysql_connect(MYSERVER,MYUSERNAME,MYPASSWORD);

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db(MYDATABASE, $con);

$rowCount=1;

$result = mysql_query("SELECT EpicPoem.*, MLBTeams.* FROM EpicPoem LEFT JOIN MLBTeams ON EpicPoem.Opp = MLBTeams.ID");

while($row = mysql_fetch_array($result))
{
if ($row['GameNum'] == 0)
..etc...
octobert
 
Posts: 3
Joined: Thu Jul 23, 2009 10:15 am
LifeType Version: 1.2.8

Re: Custom DB Table Access

Postby jondaley on Thu Jul 30, 2009 3:30 pm

And what is your error?

Are you enclosing your code in {php} so smarty knows you are trying to execute php?
jondaley
Lifetype Expert
 
Posts: 6169
Joined: Thu May 20, 2004 6:19 pm
Location: Pittsburgh, PA, USA
LifeType Version: 1.2.11 devel branch

Re: Custom DB Table Access

Postby octobert on Thu Jul 30, 2009 10:45 pm

Jon,
Sorry I wasn't clear...I'm not getting an error now, thanks to your help. I changed that template indicator and put the {php} tags around it and it is working perfectly.

I thought you wanted to know the code and error I was getting before the solution you gave me.

Thanks,
Tom
octobert
 
Posts: 3
Joined: Thu Jul 23, 2009 10:15 am
LifeType Version: 1.2.8


Return to Everything Else Goes Here!

cron