ionik
-
Posts
187 -
Joined
-
Last visited
Posts posted by ionik
-
-
TY Works Great
-
Yes i do
the first two NULL keys suggest otherwise.
the 1st table has no data in it.....
the 2nd table is the table that only has the channelid and the primary table where everything is being sorted by...
-
Yes i do
-
Heres a better explaination
the statement is as follows
SELECT ch.name, ch.channelId, ROUND( SUM( vr.rating ) / COUNT( vr.rating ), 2) as averageRating, COUNT( vt.trackId ) as viewCount, COUNT( cm.commentId ) as commentCount, COUNT( vi.videoId ) as videoCount FROM channels ch LEFT JOIN videoRatings vr ON vr.channelId = ch.channelId LEFT JOIN videoTracking vt ON vt.channelId = ch.channelId LEFT JOIN videoComments cm ON cm.channelId = ch.channelId LEFT JOIN videos vi ON vi.channelId = ch.channelId GROUP BY ch.channelId ORDER BY ch.latestVideo DESC LIMIT 0, 10
and it runs fine for explain
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE vt system channelId NULL NULL NULL 0 const row not found 1 SIMPLE ch ALL NULL NULL NULL NULL 10 Using temporary; Using filesort 1 SIMPLE cm ref channelId channelId 4 mehype.ch.channelId 310 1 SIMPLE vi ref channelId channelId 4 mehype.ch.channelId 63 1 SIMPLE vr ref channelId channelId 4 mehype.ch.channelId 325
but once I run it through the database it will completely slow down and just kill the server....and its a dedicated server....resulting in a restart every time i try to run it
the tables don't have that much data at all
the videos table has about 630 rows....the ratings has about 3,200 rows, the channel table is only 10 items and the tracking table is completely empty...
Any suggestions on this? As I am now stumped by this, and Cannot go anywhere.
-
when run as
SELECT DISTINCT ch.name, ch.channelId,
ROUND( SUM( vr.rating ) / COUNT( vr.rating ), 2) as averageRating,
COUNT( vt.trackId ) as viewCount,
COUNT( cm.commentId ) as commentCount,
COUNT( vi.videoId ) as videoCount
FROM '.CHANNELS.' ch
INNER JOIN '.VIDEO_RATINGS.' vr ON vr.channelId = ch.channelId
INNER JOIN '.VIDEO_TRACKING.' vt ON vt.channelId = ch.channelId
INNER JOIN '.VIDEO_COMMENTS.' cm ON cm.channelId = ch.channelId
INNER JOIN '.VIDEOS.' vi ON vi.channelId = ch.channelId
GROUP BY ch.channelId ORDER BY ch.latestVideo DESC LIMIT '.$start.', 10
returns no results
but
SELECT ch.name, ch.channelId,
ROUND( SUM( vr.rating ) / COUNT( vr.rating ), 2) as averageRating,
COUNT( vt.trackId ) as viewCount,
COUNT( cm.commentId ) as commentCount,
COUNT( vi.videoId ) as videoCount
FROM '.CHANNELS.' ch
LEFT JOIN '.VIDEO_RATINGS.' vr ON vr.channelId = ch.channelId
LEFT JOIN '.VIDEO_TRACKING.' vt ON vt.channelId = ch.channelId
LEFT JOIN '.VIDEO_COMMENTS.' cm ON cm.channelId = ch.channelId
LEFT JOIN '.VIDEOS.' vi ON vi.channelId = ch.channelId
GROUP BY ch.channelId ORDER BY ch.latestVideo DESC LIMIT '.$start.', 10
returns the desired result but takes about 2 1/2 minutes to run
-
Yes i have read the sticky....
I got this SQL Statement it is fairly simple and does what it needs to
SELECT DISTINCT ch.channelId, ch.name, CEIL( SUM( vr.rating ) / COUNT( vr.rating ) ) as averageRating, COUNT( vt.videoId ) as viewCount, COUNT( cm.commentId ) as commentCount, COUNT( vi.videoId ) as videoCount FROM '.CHANNELS.' ch LEFT JOIN '.VIDEO_RATINGS.' vr ON vr.channelId = ch.channelId LEFT JOIN '.VIDEO_COMMENTS.' cm ON cm.channelId = ch.channelId LEFT JOIN '.VIDEOS.' vi ON vi.channelId = ch.channelId LEFT JOIN '.VIDEO_TRACKING.' vt ON vt.channelId = ch.channelId GROUP BY ch.channelId ORDER BY averageRating DESC LIMIT '.$start.', 10
the problem that i have is that when there is a few entries in the DB it runs great once i add some data ( thousands of rows to each of those tables it completely runs out and just times out the query )
what could be the problem here?
-
NEVERMIND I solved the problem........here is the sql statement just incase anyone else runs into this problem
SELECT DISTINCT ch.channelId, ch.name, CEIL(SUM( vr.rating ) / COUNT(vr.rating)) as rating FROM '.CHANNELS.' ch RIGHT JOIN '.VIDEO_RATINGS.' vr ON vr.channelId = ch.channelId GROUP BY ch.channelId ORDER BY rating DESC
-
the only problem i have with this right now is counting the value of each rating for the videos....how can this be done?
-
OK!
What i need to do is I have 2 MySQL Tables one holds information for channel data and another holds the video data tracking data the tables are linked between the channelId's the thing i need to do
is sort out the channels by the videos that have the highest rating and the rating are stored in a new row for each one here is a graph to better explain it
VideoTracking
---------------------------
videoId | channelId | rating
---------------------------
2 | 1 | 2
---------------------------
2 | 1 | 3
---------------------------
1 | 3 | 5
---------------------------
1 | 3 | 1
---------------------------
So as you see I need to add all of the values for videos ratings and then sort by that how would i DO this?
-
Here is has worked with this framework?
I am hoping on getting a job that requires this and would like to know how others have done with it.
Is it a nice solid framework easy to learn, how are the class structures etc etc...is it easy to integrate your own class engines into the framework, what were some problems that you experienced with it if any and what were some advantages.
I'm looking to get some input and advice from others who've used it not tutorials and other info.
-
what is difference between MVC Frameworks and Templating Framework, can i use MVC within Templating Framework? because i want efficient layering too.
A template engine isnt a framework a template engine is a php application that simplifies output for your code by putting it into template files stored and parses them dynamically or statically when run.
A MVC Framework is a php application that is designed to run and develop php applications, doing a few things simply put it makes the development phase must must faster.
A template engine is something no developer can live without ( unless they want to make live hard on themselves ).
A Framework is something a developer can go years without me personally I don't use frameworks unless its required at my job, frameworks are more of a preference.
-
Hello Im Nick,
Im 20 years old with 3 step kids (20,13,and 11) and one of my own on the way due in May!! been married now for about a year and recently got out of the military. I know work as a Senior PHP developer and get to work on various types of ecommerce websites, mentoring and teaching college grads ( most of which are older than I am ). I am a completely self-taught developer and when I'm not working I'm doing freelance work and developing and planning the release of a CMS that I have built over the past year named cSystem.
Live development can be seen at http://teamicenine.com
I am a hard-core OOP programmer ( although at work we are still using PHP 4) and specialize in the security. -
to have a function return a instance of a class object you would need to have that function be a reference to that object you are trying to call.
And that error is because you are trying to call fetch_assoc on $result which appears to be a reference ID?
for example
class Test { public function __construct() { // Do something } public function thisis() { // Do something } public function thisthat() { return $this->thisis(); } }
Now of course that would be completely useless but adding in variables to the function and maybe some actions that happen that affect the thisis operation in the thisthat function.
It appears what you are trying to do would return the SQL reference to that query and not a object, I'm not sure on how your Database class operates but to me it appears your code should be this, does your DB class use caching for the last query since the refernce ID is not included for in the fetch_assoc.
while ($row = $this->db->fetch_assoc() !== NULL)
-
could not edit my post....
here is a better example I whipped up to show you.
<?php class SessionAbstractInit { protected static $instances = __CLASS__; public function Parse_All() { echo 'Parse All'; } public function getInstance() { return (is_object($instances)) ? self::$instances : (self::$instances = new self::$instances); } } abstract class SessionAbstract extends SessionAbstractInit { protected static $Init; public static $method; public function __construct() { self::$Init = SessionAbstractInit::getInstance(); // This will hold the objects of $Init } public function print_stuff() { } } class Session extends SessionAbstract { protected static $instance = __CLASS__; public function getInstance() { return (is_object($instance)) ? self::$instance : (self::$instance = new self::$instance); } public function donothing() { echo '<br /> Do Nothing!!'; } } class SessionManagement { public function __construct() { // create instance of session $this->session = Session::getInstance(); } public function show() { $this->session->Parse_All(); $this->session->donothing(); } } $session = new SessionManagement(); $session->session->Parse_All(); $session->session->donothing(); $session->show(); ?>
as you can see i created the abstract session which didn't do anything but in turn could load the class objects and turn them into a registry, and then branched two child classes off of it Session And SessionManagement.
SessionManagement loaded itself contained its getinsance and a donothing function, Session Loaded everything together into one object $this->session which held the values for all the parent classes before it.
You can see from this that you could easily modify in a loader function that will automatically load all classes into a single object in which you are trying to do
-
Your first file will not work correctly and should trigger a error ( you are trying to load the class with the incorrect naming ) welcome and Welcome will be read as two different things.
The controller class should be setup as a abstract class
function __construct()
{
parent::__construct();
}
there is no need to call this again in a second class that is a child of your controller as it is already there.
when you are trying to load the Cont2 class you are calling $this->load it need to be $this->Load->controller().
And for your instance var try changing your code for the get_instance() function to the following
protected static $instance = __CLASS_NAME__;
function get_instance()
{
return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
}
and try running this hope this helps GL With OOP~~
-
are you using PHP5+ ?
if so, you can use json_encode() when printing the data:
<?php $quote = "[quote=i9.ioa^n1k]testing this out@![/quote] Why doesn\'t this work?"; print '<img src="/csys/themes/I92/images/icons/quote.gif" onclick=\'insert_quote('.json_encode($quote).', "i9.ioa^n1k")\' border="0" alt="Quote this comment" title="Quote this comment" />'; ?>
json_encode won't work
Anyways i solved this problem with a simple modified trim.
function deeptrim($quote) { $quote = str_replace(' ', ' ', $quote); $quote = trim($quote); $quote = addslashes($quote); return $quote; }
-
Hello Everyone!
Im having a bit of a problem with white space in Javascript ( and i cannot simply just remove it )
The problem I am experiencing is I have created a few various simple functions that insert text into a textarea, the problem I am experiencing is when I try to insert something that contains white space and a line break the code doesn't work giving me a error of a unterminated string. But it works fine if there are no line breaks or white space
example works
<img src="/csys/themes/I92/images/icons/quote.gif" onclick="insert_quote('[color=#FF0000][b]Yes[/b][/color] it was crazy beyond believe :drool:', 'i9.ioa^n1k')" border="0" alt="Quote this comment" title="Quote this comment" />
Example that doesn't work
<img src="/csys/themes/I92/images/icons/quote.gif" onclick="insert_quote('[quote=i9.ioa^n1k]testing this out@![/quote] Why doesn\'t this work?', 'i9.ioa^n1k')" border="0" alt="Quote this comment" title="Quote this comment" />
the insert_quote function is
function insert_quote(quote, username) { surroundText(document.csystem_textarea.message, '[quote=' + username + ']'+quote+'[/quote]'); }
-
yahoo uses alot of php
-
yes they are secure....and if your talking about you are on a secure server just use this
cookie('user', 'data', time()+(60*15), 'path', 'domain', TRUE);
and it will only send the cookie over a secure server.....
cookies are used everywhere are give a lot more flexibilty than using sessions...
-
use cookies....
setcookie('user', 'userid', time() + (60*15));
$user = $_COOKIE['user'];
-
what are the fields in the database try using mysql_fetch_assoc and then dumping them out to see what you get
and as far as count goes it should throw u an error for a undefined constant...try just going to that page directly and see what you get
-
Ok,
Well I cant use imagemagik so lets already out of the question or i wouldnt be posting this,
what I've been trying to accomplish is cropping out the middle of a image into a new 90x60 image and cannot seem to get anything working.
Anyone know of a good function/class/snippet that does this?
-
OK I'm quite new to the javascript world...even though Im a expert php programmer...o well anyways...what this does is just switches out which div tags are visible and hidden.
This has been tested and works in FF but IE is junk as we know and doesnt like it.... is there something wrong with this? This is a simple crude way of doing it
<script type="text/javascript"> /* This will simply show and hide the boxes for upcoming recent and match stats */ function matchi9panel(id) { document.getElementById(id).style.display = 'block'; document.getElementById('link1').className = 'left_content_chooser_button_down'; document.getElementById('link2').className = 'left_content_chooser_button_down'; document.getElementById('link3').className = 'left_content_chooser_button_down'; if(document.getElementById('1').style.display = 'block' && id != '1') { document.getElementById('1').style.display = 'none'; } if(document.getElementById('2').style.display = 'block' && id != '2') { document.getElementById('2').style.display = 'none'; } if(document.getElementById('3').style.display = 'block' && id != '3') { document.getElementById('3').style.display = 'none'; } document.getElementById('link' + id).className = 'left_content_chooser_button'; } </script>
the error i get is could not get the display property....
-
This works on my localhost but when i upload it to my server to test it I get a Internal Server Error what would be causing this?
I cannot figure this out... ??? ???
heres the rewrite i have
apache version is 1.3
# ERROR DOCUMENTATIONS ErrorDocument 404 /dev/index.php?page=404 # START REWRITE ENGINE RewriteEngine on Options +FollowSymLinks # GAME FILTER PARSER # These will only be called one time we dont catergorize # games as http://site.com/game/etc we set a cookie for that # Game Filter RewriteRule ^game_filter/([0-9]+)?$ index.php?page=game_filter&game_id=$1 [N] # Main RewriteRule ^/([A-Za-z-_0-9]+)/?$ index.php?page=$1 [N] # News RewriteRule ^/([0-9]+)?$ index.php?p=$1 [NC,L] RewriteRule ^news/([A-Za-z]+)?$ index.php?page=news&func=$1 [NC,L] RewriteRule ^news/view_news/([0-9]+)?$ index.php?page=news&func=view_news&news_id=$1 [NC,L] RewriteRule ^news/post_comments/([0-9]+)?$ index.php?page=news&func=post_comments&news_id=$1 [NC,L] RewriteRule ^news/post_comments/([0-9]+)/([0-9]+)?$ index.php?page=news&func=post_comments&news_id=$1"e_id=$2 [NC,L] RewriteRule ^news/view_news/([0-9]+)/([0-9]+)?$ index.php?page=news&func=view_news&news_id=$1&p=$2 [NC,L] RewriteRule ^news/delete_comment/([0-9]+)?$ index.php?page=news&func=delete_comment&comment_id=$1 [NC,L] RewriteRule ^news/delete_comment/([0-9]+)/1?$ index.php?page=news&func=delete_comment&comment_id=$1&confirm=1 [NC,L] RewriteRule ^news/edit_comment/([0-9]+)?$ index.php?page=news&func=edit_comment&comment_id=$1 [NC,L] # User RewriteRule ^user/([A-Za-z_]+)?$ index.php?page=user&func=$1 [NC,L] # Shows a user login with username prefilled RewriteRule ^user/login/([0-9]+)?$ index.php?page=user&func=login&userid=$1 [NC,L] ## Account Validation RewriteRule ^user/validate_account/([0-9]+)/([A-Za-z-_0-9]+)?$ index.php?page=user&func=validate_account&userid=$1&validation=$2 [NC,L] # Profile Views They are done By two ways CLan Members and Regular users CM = /players Users = /members RewriteRule ^users/members/(.*)?$ index.php?page=profile&user=$1 [NC,L] RewriteRule ^users/players/(A-Z0-9_-]+)?$ index.php?page=profile&user=$1 [NC,L] # Roster # Matches # Forums
[SOLVED] log query errors?
in PHP Coding Help
Posted
this would be much easier if you setup a MySQL Wrapper Class....
example
query Function :
mysql_query($this->sql) or $this->logError();
and your logError funciton would simply be
mysql_query('INsert ERROR');
die('Message');