| | |
PDO Number of Total Queries per Page
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
Hi Community!
I have already searched the whole web about this Problem, and I didn't find anything. Maybe you can help...
I want to show the number of all SQL queries I executed to load a web page. It is a very complex system I programmed, and I don't want to count them manually. I use PDO for this, so I can't easily write a function
I have already tried to write my an "myPDO"-class, extended from PDO, to do this job, but it didn't work.
Gave those Errors:
Thanks for help
Paul
I have already searched the whole web about this Problem, and I didn't find anything. Maybe you can help...
I want to show the number of all SQL queries I executed to load a web page. It is a very complex system I programmed, and I don't want to count them manually. I use PDO for this, so I can't easily write a function
count_query($sql) which increases a counter and return query($sql) I have already tried to write my an "myPDO"-class, extended from PDO, to do this job, but it didn't work.
PHP Syntax (Toggle Plain Text)
class myPDO extends PDO{ var $myOwnCount =0; public function __construct($location,$user,$pass) { parent::__construct($location,$user,$pass); } public function exec($q){ $this->myOwnCount ++; return parent::exec($s); } public function query($q){ $this->myOwnCount ++; return parent::query($s); } }
PHP Syntax (Toggle Plain Text)
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\...\functions.php on line 52 Fatal error: Call to a member function fetch() on a non-object in C:\xampp\htdocs\...\index.php on line 69
Thanks for help
Paul
0
#2 Oct 24th, 2009
•
•
•
•
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\...\functions.php on line 52
•
•
•
•
Fatal error: Call to a member function fetch() on a non-object in C:\xampp\htdocs\...\index.php on line 69
$class = new YourClassName();
Or declare fetch as a static public function(), but when you access it you call it like
YourClassName::fetch($arguments_here_if_any);
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#3 Oct 24th, 2009
I Create the Object like this:
If I use PDO instead, it works:
Functions.php around line 52:
The Problem is that you can use the PDOStatement in foreach like an Array. My class doesn't support this, but it should because it is extended from PDO...
PHP Syntax (Toggle Plain Text)
$dataBase = new myPDO($location, $user, $pass);
PHP Syntax (Toggle Plain Text)
$dataBase = new PDO($location, $user, $pass);
Functions.php around line 52:
php Syntax (Toggle Plain Text)
$sql = $database->query("SELECT id,title FROM general"); foreach ($sql as $general) $generalData[$general["id"]] = $g["title"];
Last edited by opatut; Oct 24th, 2009 at 3:11 pm.
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#5 Oct 24th, 2009
I FOUND IT!!!
This cant work! Thanks for helping, but it was - of course - a little mistake.
Paul
public function query($q){ $this->myOwnCount ++; return parent::query($s); }
This cant work! Thanks for helping, but it was - of course - a little mistake.
Paul
Last edited by peter_budo; Oct 25th, 2009 at 6:59 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
![]() |
Similar Threads
- memorising requested variables after page reset (PHP)
- Front Page error when opening .HTM file (HTML and CSS)
- How to Refresh a PHP page and add a clickable link (PHP)
- How do you only display 8 rows per page? PHP/MYSQL (PHP)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- total per page (Visual Basic 4 / 5 / 6)
- how can i make a total field by page in Crystal Report 11 (VB.NET)
Other Threads in the PHP Forum
- Previous Thread: block js injections through php
- Next Thread: Really stupid
| Thread Tools | Search this Thread |
Tag cloud for number, php, query, sql
.net access account ajax ajaxhelp api array asp autosuggest basic beginner c# c++ class close cms connection curl data database date developer development display dropdown dynamic editor email execution file files flash form forms function html ibm image include integration java javascript jquery lamp limit link linux login loop mail menu microsoft ms msdn multiple mysql network news number numbertoword office oop oracle paypal php post prime query random read regex remote report script search security server session sms snippet soap software spam specific sql survey traffic tutorial up-to-date upload validation vb.net vbulletin video vista web webdesign xml youtube zend






