Nov 07
Discussion From Work…
Here are just a few articles to back up my statements that the logic _should_ stay out of the database. If you have some feedback you want to provide I’m always open and can be swayed to the Stored Procedure way - but, they do have to be compelling arguments.
Quote(s) straight from MySQL:
“However, stored procedures of course do increase the load on the database server system, as more of the work is done on the server side and less on the client (application) side.”
“Triggers and Stored procedures are wonderful tools, but they come with a price. Enforcing the business rules at the database level allows you to be confident that the data conforms. There are a few cautionary notes however.
The first is that you will probably end up creating your own procedural language which will differ from the other procedural language and start to introduce further discrepancies. If possible, using an existing language and creating an interpreter for it would be preferable. Although I am fluent in Oracle PL/SQL and SQL Server 2000 T-SQL, I know that I would really rather not be. It would be an advantage to me to be able to use a standard language so that I could leverage those skills elsewhere. A database where I had to learn yet another proprietary instruction set would make me dubious of wanting to get involved with it.
Performance will degrade and it will take awhile to get it to a satisfactory level. This does not take anything away from the development team, it has been true of every database system when they have done this. DB2 still has a reputation of being slow and a memory hog when you use their triggers and stored procedures. Teradata only recently added the ability to use them and it implemented them so poorly that nobody wants them. Be prepared for the performance hit and the resulting aftermath.
A possible way around this would be to include further support for server software that applies the business rules without actually being on the database. J2EE, for example, could be utilized with Enterprise Java Beans and have the exact same net effect as having stored procedures and triggers, without actually having to modify the database.”
–This also brings up a very good point… look at mysql system requirements… less of a system is needed, where as with stored procedures you need a workhorse with loads of RAM to cache all of those stored ‘compiled’ procedures. Not to mention including the processor time needed to compile the stored procedures in the first place (don’t forget page-swapping to handle all the memory requirements, reloading of the stored procs at restart… I could go on…).
http://dotnetjunkies.com/WebLog/johnwood/archive/2005/01/19/46398.aspx
http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx
http://www.windowsitpro.com/sqlserver/forums/messageview.cfm?catid=1669&threadid=130201
On a lighter note: What happens with more procedure calling than is necessary in JAVA?
http://madbean.com/anim/jarwars/
May 06
I have been using a package from http://www.entropy.ch/software/macosx/php/ to get an up to date version of PHP for OS X Server. I really like the package and it’s options work great and do an excellent job of keeping up to date as well as making sure they do not break the default Apple settings.
I have recently had to use MSSQL 7.0 database to connect to some legacy data. I use ADODB to extract the SQL layer so I could change the database connections one it was all ported. Here is the only thing I had to add to get it to connect.
I have learned that in order to get ADODB to connect to MSSQL server (v7.0) you have to modify /usr/local/php/etc/freetds.conf (/usr/local/php5/etc/freetds.conf) by adding an entree such as this.
[sql.example.com]
host = sql.example.com
port = 1433
tds version = 7.0
The host has to match the entree for ADODB to pick it up. This works for both 4.3.x and 5.0.x.
Just thought I would share with the online community.
BTW: Many thanks for Marc for including FreeTDS. You have made our server migrations from various platforms to OS X so much easier.
Mar 06
So, I’ve been a little busy at work. Let’s just say with Chris passing on, someone leaving the company, and sort of new hire(3 almost 4 months) out with back problems… my life has been nothing but boring. It’s great being the one person the entire company counts on seriously. Trial by fire is important it builds character, experience, and at the core sees how well you manage under extreme pressures. It keep thinking of the Army of one jokes. I’m the IT of one. Which leads me to the reason for my post.
Code!
I’ve found that lately I’ve been in research mode… very code productive lately. As a result this was created. I posted this on php.net but thought since it is my own work I’ld post it here just in case something happened to it.
Start Original Post
I figured out a way to create a simple progress bar that is for the most part cross platform. Seeing as I got my ideas from this site (http://www.php.net) it’s only share to give back to the community.
Note: Something interesting about browser buffering… you have to have the < html >< body > for Firefox and some other browsers to recognize items by their id in Javascript. So I recommend using some sort of header function before calling this function.
Code
< ? php
function fn_progress_bar($intCurrentCount = 100, $intTotalCount = 100)
{
static $intNumberRuns = 0;
static $intDisplayedCurrentPercent = 0;
$strProgressBar = '';
$dblPercentIncrease = (100 / $intTotalCount);
$intCurrentPercent = intval($intCurrentCount * $dblPercentIncrease);
$intNumberRuns++;
if(1 == $intNumberRuns)
{
$strProgressBar = <<< BAR
< table width='50%' id='progress_bar' summary='progress_bar' align='center'>< tbody>< tr>
< td id='progress_bar_complete' width='0%' align='center' style='background:#CCFFCC;'> < /td>
< td style='background:#FFCCCC;'> < /td>
< /tr>< /tbody>< /table>
< script type='text/javascript' language='javascript' >
function fn_progress_bar_update(intCurrentPercent)
{
document.getElementById(’progress_bar_complete’).style.width = intCurrentPercent+’%';
document.getElementById(’progress_bar_complete’).innerHTML = intCurrentPercent+’%';
}
< /script >
BAR;
}
else if($intDisplayedCurrentPercent <> $intCurrentPercent)
{
$intDisplayedCurrentPercent = $intCurrentPercent;
$strProgressBar = < << BAR
< script type='text/javascript' language='javascript' >
fn_progress_bar_update($intCurrentPercent);
< /script >
BAR;
}
if(100 < = $intCurrentPercent)
{
$intNumberRuns = $intDisplayedCurrentPercent = 0;
$strProgressBar = <<< BAR
< script type='text/javascript' language='javascript' >
document.getElementById(’progress_bar’).style.visibility=’hidden’;
< /script >
BAR;
}
echo $strProgressBar;
flush();
ob_flush();
}
?>
End Original Post
Example
< ? php
$intTotal = 5000;
for($intCounter = 0; $intCounter <= $intTotal; $intCounter++)
{
fn_progress_bar($intCounter, $intTotal);
}
? >
Future Ideas
- Make it so you can have several unique progress bars per page with their own progress.
- Make sure it is as close to 100% cross-browser as possible.
Credits
If you copy and paste be sure to give credit.
If you do find this useful comment here, Thanks.
Sep 16
Note: In response to a PHP discussion in a wiki.
Please consider the follow:
There are certain programming languages created to serve certain
purposes. Just as there are certain color, styles, and types of
automobiles to suit your personal needs. Programming languages are
designed for purposes determined by the creator to solve their (not
necessarily your) problems. Many times they create features not
addressed in other languages. Often times they mimic the behavior of
other languages they like.
If type checking is what you want use a language that has it. We as
programmers should not complain about this language not having this
feature, and this other language not having this feature. I believe,
and this is my own opinion, we should concentrate on using the right
programming language for the right task at hand. We are the intelligent
nerds, which pride ourselves on our capabilities and pure ingenuity
when it comes to solving complex problems. So quit flaming and
complaining and start acting like mature professional programmers and
show the world what your capable of.
The best way I can compare the right language to the right job would be like a woodshop craftsman using the right type of chisel for the detailing. You could use any one you want, we use whatever IDE suites our fancy and if we do not find one we like we can always make our own. Just a like a craftsman would. Programming is a skill, and just like any skill it takes time and patients to learn the right tool to use for the right job.
The best examples I can give are programs that use several languages.
These programs use each language where it is best suited by using the
most ǃÚefficientǃ٠syntax were it is needed. Kernels are a common example
of this.
I call on all programmers out there to learn as much as possible about
as many languages as possible. This way you will be able to decide what
programming language to use for the job, and not waste your time and
our time complaining that X language does not have Y feature.
In short use the language that is best suited for ǃÚyourǃ٠problem!
Jun 09
I find this blogging to be rather interesting. I would like to take this post to express a quick look at what it has done to the online community.
First off I have noticed a lot of people or reading and actually creating communities of religious (almost) followers to sites. I have to admit that Eric Meyer does an excellent job of explaining CSS and other online technologies. I find myself at least spending 5 - 10 minutes on the site everyday looking up CSS, or reading some his latest observations. This strange occurrence of followers is a kind of new/old devotion. I can remember when people would devote themselves to certain BBS and in the attempt to access to ‘hidden’ areas of the system.
Second, I can not help but talk about freedoms of expression and speech. Personally, I find it fascinating to see the level of self editing that goes on. I was quite surprised to see lots of personal information on certain sites which tend to for the most part be reserved in their writing. I’m still trying to figure out why this is.
Third, topics of discussion are just random! I can’t believe peoples postings sometimes. I realize that this last sentence could come back to haunt me but, oh well. I’ve learned more about the dynamics of people and what their hobbies and interests are by reading various blogs. I consider this random topic occurrence to be all part of the chaos theory but, only time will tell.
Conclusions to be drawn at a later time…
Well the following was just something I was thinking about off the top of my head. I figured I would use this blog as a sort of journal and collection of random thoughts so we see what it grows into.
Programming: Today I’m attempting to get a PHP/XHTML form to post to itself until the users entities are completely validated. Once, validated I want the application to POST the (validated POST values) to another URL. We shall see where it goes from here. JS or Sockets that is the question. I’ve been trying to use the PHP.net comments to build something but nothing seems to work. Back to the drawing board. We shall have to see what I come up with to solve this problem. In the mean time if anyone has a working online example please contact me.