Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2009-07-20 04:06:39

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Cash logs, i made, i need to pull imgaward :)

here is my query that pull's up from my table "cashlogs"

$result = $db->query('SELECT * FROM cashlogs ORDER By time DESC LIMIT '.$start_from.', 25') or error('Unable to fetch log info', __FILE__, __LINE__, $db->error());
        

Here is a screenshot on what I pull smile

28u04xy.jpg

I would love it  so I can pull my field imgaward from the user's table and apply them to each from_name and to_name fields in my cashlogs table. smile Possible?

I am trying to act professional and nice as i can please help me on this what, thanks!

I am asking you for help because I don't want to use WHERE Statement. because then I Would have like 250 Querys.. lol


hey

Offline

#2 2009-07-20 08:44:50

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,165
Website

Re: Cash logs, i made, i need to pull imgaward :)

What is the structure of the cashlogs table? I assume it has a from and to field that contains the users id, or from_id and to_id field as well as from_name and to_name?

Offline

#3 2009-07-20 20:17:43

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

Reines wrote:

What is the structure of the cashlogs table? I assume it has a from and to field that contains the users id, or from_id and to_id field as well as from_name and to_name?

yes, the structure is:

s3imp3.jpg


hey

Offline

#4 2009-07-20 22:37:09

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,165
Website

Re: Cash logs, i made, i need to pull imgaward :)

Try replacing the current query with something like:

SELECT cl.*, f.imgaward AS from_imgaward, t.imgaward AS to_imgaward
FROM cashlogs AS cl
INNER JOIN users AS f ON f.id = cl.from_id
INNER JOIN users AS t ON t.id = cl.to_id
ORDER By cl.time
DESC LIMIT '.$start_from.', 25

Offline

#5 2009-07-21 00:50:24

elbekko
Former Developer
From: Leuven, Belgium
Registered: 2008-04-30
Posts: 1,131
Website

Re: Cash logs, i made, i need to pull imgaward :)

Why on earth is everything there a text type?

A thousand DBAs just killed a puppy.


Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Offline

#6 2009-07-21 01:58:46

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,135
Website

Re: Cash logs, i made, i need to pull imgaward :)

I second Bekko:

s3imp3.jpg

YoumakeJesusCry.jpg

Offline

#7 2009-07-21 06:14:38

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

Smartys wrote:

I second Bekko:

s3imp3.jpg

YoumakeJesusCry.jpg

Why would i make jesus cry? showing a screenshot? lol smarty u never help, u always just say something arrogant.. like that Reines (<3) === posted a query that i could use but u never do that, lol u dont like me or something ? sad

Last edited by Nick Newman (2009-07-21 06:15:36)


hey

Offline

#8 2009-07-21 06:16:42

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

elbekko wrote:

Why on earth is everything there a text type?

A thousand DBAs just killed a puppy.

Text is the best way, why?  is that insecure?


hey

Offline

#9 2009-07-21 11:22:02

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,135
Website

Re: Cash logs, i made, i need to pull imgaward :)

Nick Newman wrote:
elbekko wrote:

Why on earth is everything there a text type?

A thousand DBAs just killed a puppy.

Text is the best way, why?  is that insecure?

I have to say, that's a great quote tongue

Text is not the best way. Modern databases have established types for use in columns. Integers can be TINYINT, SMALLINT, INT, MEDIUMINT, BIGINT, etc. Smaller bits of text can be VARCHAR, CHAR, etc. By assigning a type (as opposed to shoving everything into TEXT columns) the database can be smarter about storage and about how the data is interpreted.

For instance, in your query, you join the users table twice. You join on two columns which are TEXT, which will make your query incredibly slow. Those columns should be INTs, just like their corresponding columns in the users table.

Offline

#10 2009-07-21 11:25:58

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,135
Website

Re: Cash logs, i made, i need to pull imgaward :)

Nick Newman wrote:

Why would i make jesus cry? showing a screenshot? lol smarty u never help, u always just say something arrogant

Well, I was actually just agreeing with Elbekko. However, you obviously have forgotten the previous times you showed up and asked for "help"

http://punbb.informer.com/forums/search … k%20Newman

Offline

#11 2009-07-21 11:47:09

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,165
Website

Re: Cash logs, i made, i need to pull imgaward :)

elbekko wrote:

Why on earth is everything there a text type?

A thousand DBAs just killed a puppy.

Jesus I didn't even notice that, just looked at the field names neutral

Offline

#12 2009-07-21 12:03:26

MattF
Member
From: South Yorkshire, England
Registered: 2008-05-06
Posts: 1,230
Website

Re: Cash logs, i made, i need to pull imgaward :)

Reines wrote:

Jesus I didn't even notice that, just looked at the field names neutral

You obviously have an extrememly critical eye. big_smile big_smile


Screw the chavs and God save the Queen!

Offline

#13 2009-07-21 12:54:52

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,165
Website

Re: Cash logs, i made, i need to pull imgaward :)

hmm

Offline

#14 2009-07-21 19:13:38

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

Smartys wrote:
Nick Newman wrote:
elbekko wrote:

Why on earth is everything there a text type?

A thousand DBAs just killed a puppy.

Text is the best way, why?  is that insecure?

I have to say, that's a great quote tongue

Text is not the best way. Modern databases have established types for use in columns. Integers can be TINYINT, SMALLINT, INT, MEDIUMINT, BIGINT, etc. Smaller bits of text can be VARCHAR, CHAR, etc. By assigning a type (as opposed to shoving everything into TEXT columns) the database can be smarter about storage and about how the data is interpreted.

For instance, in your query, you join the users table twice. You join on two columns which are TEXT, which will make your query incredibly slow. Those columns should be INTs, just like their corresponding columns in the users table.


Ok sir..  I changed those INT's

net452.jpg


now what should i do with this:

SELECT cl.*, f.imgaward AS from_imgaward, t.imgaward AS to_imgaward
FROM cashlogs AS cl
INNER JOIN users AS f ON f.id = cl.from_id
INNER JOIN users AS t ON t.id = cl.to_id
ORDER By cl.time
DESC LIMIT '.$start_from.', 25

You said now my query will be alot faster now because there not text smile

Thanks in advance Reine's!


hey

Offline

#15 2009-07-21 19:50:39

elbekko
Former Developer
From: Leuven, Belgium
Registered: 2008-04-30
Posts: 1,131
Website

Re: Cash logs, i made, i need to pull imgaward :)

So you actually managed to make two out of four fields that shouldn't be an int into an int, but not those that actually should be. Congratulations.


Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Offline

#16 2009-07-21 19:52:04

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

elbekko wrote:

So you actually managed to make two out of four fields that shouldn't be an int into an int, but not those that actually should be. Congratulations.

If u read his post it say only the 2 ones he calling from Database...


hey

Offline

#17 2009-07-21 20:01:33

Tyler
Member
Registered: 2008-05-11
Posts: 104

Re: Cash logs, i made, i need to pull imgaward :)

Sorry to ruin the fun, but I felt like being nice. tongue

Names should be varchars, not ints.  Ints are numbers.

You want these as ints:
to_id
from_id
amount
time
page

These as varchars:
from_name
to_name
type

This as a text:
msg

Now, depending on what you're doing with type, it may be either an int or a varchar.

Last edited by Tyler (2009-07-21 20:02:05)

Offline

#18 2009-07-21 20:54:23

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

Smartys wrote:
Nick Newman wrote:
elbekko wrote:

Why on earth is everything there a text

For instance, in your query, you join the users table twice. You join on two columns which are TEXT, which will make your query incredibly slow. Those columns should be INTs, just like their corresponding columns in the users table.

NOw im confused on what tyler says?

Last edited by Nick Newman (2009-07-21 20:54:37)


hey

Offline

#19 2009-07-21 21:12:17

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,165
Website

Re: Cash logs, i made, i need to pull imgaward :)

It's joining on from_id and to_id not on from_name and to_name, you changed the wrong ones smile

What Tyler said is right.

Offline

#20 2009-07-21 21:40:44

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

Ok so i changed them varchar, will the query look different? and if how so can u post it down, thanks tyler and Reines in advance.


hey

Offline

#21 2009-07-22 22:19:30

Tyler
Member
Registered: 2008-05-11
Posts: 104

Re: Cash logs, i made, i need to pull imgaward :)

Nick Newman wrote:

Ok so i changed them varchar, will the query look different? and if how so can u post it down, thanks tyler and Reines in advance.

It shouldn't look different.

Offline

#22 2009-07-23 06:33:22

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

Tyler wrote:
Nick Newman wrote:

Ok so i changed them varchar, will the query look different? and if how so can u post it down, thanks tyler and Reines in advance.

It shouldn't look different.

Why was slavok saying it will make db look slow?


Or does it just generally go faster bcz there not all texts? lol


hey

Offline

#23 2009-07-23 16:35:26

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 4,070
Website

Re: Cash logs, i made, i need to pull imgaward :)

Nick Newman wrote:

slavok

Try to stay in one forum/topic, please...


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#24 2009-07-23 19:22:26

Nick Newman
Member
From: <b>test</b> [b]hey[/b]
Registered: 2008-05-19
Posts: 22
Website

Re: Cash logs, i made, i need to pull imgaward :)

lie2815 wrote:
Nick Newman wrote:

slavok

Try to stay in one forum/topic, please...

wat r u talking about? rofl


hey

Offline

#25 2009-07-23 21:29:07

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,165
Website

Re: Cash logs, i made, i need to pull imgaward :)

Slavok is part of PunBB, I assume you posted it on both PunBB and FluxBB forums. He hasn't replied here so no-one knows what you mean.

Offline

Board footer

Powered by FluxBB 1.5.0