| | |
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 34 Days Ago
•
•
•
•
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 34 Days Ago
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; 34 Days Ago at 3:11 pm.
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#5 34 Days Ago
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; 33 Days Ago 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 |
.net adobe advanced ajax archive array asp automatically basic beginner body broken c# c++ class cms code connection cookies curl data database delete derby developer development display dropdown eclipse ecommerce email execute explodefunction external files flash form forms google hacker html image include java javascript jquery key lamp limit line link linux local login mail menu microsoft mobile ms msdn multiple mysql netbeans news number office oop php post prime programmer protocol query recursiveloop remote report script search security server sms smtp software spam sql survey trim tutorial upload vb.net vbulletin video vista web websitecontactform window word wpf youtube zend






