MooTools Table Sorter version 0.9.5 October 13, 2009
Posted by chris in : ajax/dom/javascript , add a commentI’ve added some additional features to TableSorter (originally featured here). I fixed some bugs in the removeParameter function, added a removeAllParameter function, and added a reloadView function. The new version has nicer default CSS and provides you with a pretty default table reload feature.
Check out the demo page. Post any questions here please.
mysql get total rows in query with sql_calc_found_rows August 13, 2009
Posted by chris in : SQL , add a commentThe MySQL SQL_CALC_FOUND_ROWS function is a nice way to return how many rows were returned in the query. There has been a lot of discussion in the PHP.net entry on mysql_num_rows regarding this function. The debate centers around whether its more effecient to use MySQLs built in functionality or whether its more effecient to run the same query again using the COUNT() function.
For me, its hard to determine which way is better. Usually its better to leverage your database engine than code. There is not an easy way to tell how database cache plays into this either. I feel using SQL_CALC_FOUND_ROWS is the better option, it eliminates a few extra lines of code, and prevents you from having to update multiple queries. Whether there is a performance penalty in either case is debatable, if its even noticeable…
SELECT SQL_CALC_FOUND_ROWS * FROM tbl_customer WHERE entry_date > '2009-01-01';
In a separate query run this (I believe this is connection dependent, so they must be run in conjunction with each other within the life of the same connection).
SELECT FOUND_ROWS() as totalRows;
best way to load your JavaScript July 30, 2009
Posted by chris in : ajax/dom/javascript , add a commentInteresting article over at Ajaxian on loading your javascript code. I’m not sure this is the best way in all cases, but when you’re coding in a world of frameworks, multiple js files, wysiwyg editors, and framework plugins and widgets it definitely makes sense in many circumstances.
google wave, next generation collaboration platform, google exchange killer July 24, 2009
Posted by chris in : rant , add a commentReading Slashdot I came across this article on Googles latest yet-to-be-released product called, Google Wave.
http://developers.slashdot.org/story/09/07/22/220226/Google-Wave-Reviewed
I was interested enough to sit through the 1 hour video demo on the product and it was worth every minute. I am thoroughly ecstatic about this product and the Google Wave API makes the possibilities endless. Think about all those iphone style apps or all those great FireFox Addons rolled into an enterprise (or something great for you and some friends) collaboration suite.
In thinking about Wave, Google thought about what they would include in email if they could completely rewrite it today. What they ended up doing is making email interactive like an instant messenger client, to the point where you can see what recipients (yes thats plural you can add multiple people to an email) is typing character by character as it happens real time. Now say you add a new person to a “thread” that has hundreds of responses, enter the playback feature. You can playback the life cycle of the thread, message-by-message and edit-by-edit from beginning to the most recent response. This thing is jam packed with other neat features like a slick drag and drop photo gallery (gears only right now but they are pushing to get it adopted into HTML 5), spell checker, setting pieces of a thread private etc.
The whole thing is open source so you’re not locked into Google as your Wave vendor. You can install it at home or work and modify the code to tailor the Wave to your organizations needs. If modifying the application is a bit much you can tie into the Wave API and create your own extensions. If you have an hour and twenty minutes to kill I would watch the demo, it really is awesome!
adventures in linux printing, set default printer and firefox command line print July 23, 2009
Posted by chris in : linux, php , 2commentsWe are in the process of redesigning our packing slips that get sent out to customers with each order. The previous developer went with a solution, html2ps, that has shotty support for CSS and design principals in general. The designer and I decided we needed something else. After trying numerous solutions, a co-worker suggested I give FireFox command line print a try.
firefox 3.5 fails – bug with ajax callback onreadystatechange July 17, 2009
Posted by chris in : rant , add a commentI first noticed this bug a few days after upgrading to FireFox 3.5. When you fire an XHR request, the callback function is not being executed when the request completes itself. Instead you see an onreadystatechange error in Firebug.
There have been several bugs reports on this:
http://www.nczonline.net/blog/2009/07/09/firefox-35firebug-xmlhttprequest-and-readystatechange-bug/
http://www.ghastlyfop.com/blog/2007/01/onreadystate-changes-in-firefox.html
My advice is don’t upgrade too FireFox 3.5 until they have released a patch for this bug. Its incredibly annoying to keep retrying your XHR request until it finally succeeds knowing your code is just fine. I have downgraded both my systems to FireFox 3.0.11. My bigger concern is how this ever got passed of by QA?
new TableSorter mootools widget for sorting tables July 9, 2009
Posted by chris in : ajax/dom/javascript , add a commentPlease see the version 0.9.5 blog post
(more…)
zend studio 6 fails – going back to zend 5.5 June 6, 2009
Posted by chris in : rant , 3commentsZend, the PHP Company, took a major step back with their PHP IDE when they moved it too the eclipse platform. I’m not a fan of eclipse, I don’t even like using it for Java development – which its built for. Zend Studio 6 is slow, clunky, the user interface is confusing, the FTP component is horrible.
If you can name it, Zend 5.5 beats Zend 6 at it, except for javascript support. However, I only need a JavaScript IDE for when I am doing heavy JavaScript coding or debugging. The worst part about Zend Studio 6 is the FTP component. Every time you save a file – it refreshes the folders and closes them all. So you can to open the folder again and wait everytime you make a save! Finally I decided to update the program hoping they had fixed this bug. When I updated to the latest version I was no longer able to connect to most of the FTP servers I had (roughly 10), one of which was to this domain.
At the point I uninstalled and went back to Zend 5.5 and wrote this article. Flat out, Zend Studio 6 sucks.
mysql with rollup for a easy grouped total columns in result set June 4, 2009
Posted by chris in : SQL , add a commentUsing the WITH ROLLUP modifier in queries using GROUP BY will add an additional row to the result set which sums all columns. This prevents you from having you to write code which adds each column in your programming language.
Description from the Mysql Reference Manual
The GROUP BY clause allows a WITH ROLLUP modifier that causes extra rows to be added to the summary output. These rows represent higher-level (or super-aggregate) summary operations. ROLLUP thus allows you to answer questions at multiple levels of analysis with a single query. It can be used, for example, to provide support for OLAP (Online Analytical Processing) operations.
Example
SELECT DATE(dateTime) AS order_date, count(*) as shipments, sum(shipping_total) as shipping_total, sum(hasShipAmt) as hasShipAmt, sum(shipping_total)-sum(hasShipAmt) AS revenue FROM tbl_my_orders WHERE dateTime BETWEEN '$startDate' AND '$endDate 23:59:59' GROUP BY order_date WITH ROLLUP
star uml, the best free open source uml flow charting software May 27, 2009
Posted by chris in : software , 3commentsA few months ago I was rummaging around my office for a copy of MS Visio, my favorite diagramming tool. Unfortunately I had misplaced it and did not feel like buying a new copy or swiping a pirated version. The free alternatives that I knew of at the time were lacking. My general opinion of most open source desktop software is not that high. The open source community has done great with web apps and server side software, but office tools aren’t really there yet.
Dia is aesthetically appalling and is prone to crashing and umlet is cumbersome and not much better looking. Enter Star UML. Star UML might even be better than Visio. Some of my favorite star uml features are the code generator (supports many languages including PHP), the documentation generator (exports to Word), and the ER diagram. Star UML supports UML diagraming with activity diagrams, use-case models, class diagrams, and many more. Additional extensions give you support for ER database diagrams as well.
I’ll actually write a decent-sized article this time since I feel many of the awesome features in Star UML are unfortunately poorly documented.
PHP Code Generator
The Code generator supports many languages by default, but you will have to download the plugin from the star uml website to get PHP support. Once the plugin is installed (done by simply dropping some files in a plugin folder). Click Tools, then StarUML Generator. In the select the checkbox to the left of “PHP 5 Code Generator v1.0″ and then click Next. Follow the remaining steps are your class diagrams will be converted into wonderful PHP 5 classes. The more time you spend following UML standards, the better the generated code will be.
ER Diagram
This is another plugin that can be downloaded from the Star UML project website. This one took some discovery to get working and unfortunately there isn’t a MySQL code generator for this yet. However the tool works pretty well. Once the plugin has been placed in the right directory and is installed (follow the directions on the project website) you can begin using it.
Open a new project. Select the default option. In your Model Explorer to the right you will see the name of your Model, probably called Untitled with a cube to the left of it. Right-click, select Add, then select Model. Name your model something, how about ER Diagram. Now right click ER Diagram and click Add Diagram, then select ER(IE) Diagram. Now to the left you will see some options for adding a table and linking tables through relations.
Lets add a table, name it anything. By default the table will not be what you want. I named by table “tbl_yo” which now appears in the model explorer. Select the table in the model explorer. In the tables properties (located just below the model explorer) there will be a value called Stereotype. Click the button to the right that has three dots. The stereotype you want to select is called table (ERD). Your table should look a bit different now (the table title is located just above the yellow square. Now add a column called yo_id. This can be done by double-clicking the table and clicking the greenish button. In the model explorer you will see yo_id below tbl_yo. Right click yo_id and select Tagged Values. Checking the PK box will make this a primary key and checking the FK box makes it a foreign key. Selecting either of these will change the logo next to yo_id in the ER view.
That’s all for now, more later. Post if you have any questions.