| | |
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 30 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 30 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; 30 Days Ago at 3:11 pm.
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#5 30 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; 29 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 |
2008 access action ajax ajaxcode array asp basic beginner c# c++ class cms college confirm connection curl data database developer developers development display dropdown email fatalerror files flash folder form forms game guessing hosting html image include insert java javascript jquery js libcurl limit link linux login mail menu methods microsoft ms msdn multiple mysql news number office oop paging password php post prime programing projectmanagement qt query read remote report rss script search searchmonkey security server sharepoint sms software sophos spam sql sqlserver survey tutorial upload uploadatextfile validation variable vb.net video view vista web webdesign xml ydn youtube zend






