Frameworks Part Trois (or, Sometimes when you're right, you're wrong)

Yesterday I posted about my experience trying out CI, Cake, and Kohana side by side while I work on my super-cool-blah-blah-blah idea. I mentioned how I was unable to retrieve lists of things with Cake and Kohana, and how quickly I got through things using CI + DataMapper.

Well, Houston, we hit a problem.

Last night I realized that DM was not encoding passwords before inserting/updating them in the database. I ended up changing it to just encode the posted password value and insert (not an ideal solution, IMO). This morning I was making a few other changes and running some tests and I realized something huge.

DM was not validating any of the data.

Obviously, this is a HUGE concern, and not one I was particularly interested in trying to track down and fix. On a whim I decided to give Kohana one more try, and holy [expletive] am I glad I did.

I have no idea what I was doing wrong yesterday with the ORM library but today it’s been working flawlessly (knock wood). It’s validating things the way it should, inserting and updating the way it should, and (hopefully) will help maintain the relationships the way it should.

As far as the rest of the functions and such, it was extremely easy to switch things from CI to Kohana (the fact that I’m only about 4 files in helps ;)). I’ve been able to find/figure out pretty much everything from the docs on their site and a little googling.

At this point, assuming the ORM continues working the way it should, I feel pretty good that I’ll finish up this project with Kohana.

Side note: I found a module at that’s called “Debug Toolbar” and it’s pretty sweet. It shows execution time, memory consumption, all db queries, and other nerdy goodies for the developer to use. It sits at the top of the browser, out of the way, and is slightly transparent. Cool stuff!

Frameworks, My Opinion Part Deux

Earlier this week I had a super-awesome-omg-eureka idea for a program. This idea was so hot that I put the forum project on the back burner so I could concentrate on this new idea – something I never do.

As I’ve mentioned here before, I love CodeIgniter. It’s fast, it’s simple, and it’s flexible. However, I decided for this project to try my hand (again) with CakePHP and Kohana, sort of creating side (CI) – by side (Cake) – by side (Kohana) to see which I was able to develop with faster.

For CI, I used CI 1.7.1 with DataMapper for ORM capabilities.
For Cake, I used the latest 1.2
For Kohana, I used the latest 2.3.1 and utilized the ORM library

Now, I was well aware that I would need to reference a lot more for Cake and Kohana, since I only had passing experience with them.  My biggest focus with them was database interaction since this app is database-driven.

I’m still pretty new to ORM, and perhaps there was something I missed, but I absolutely could not get a list of records using Cake or Kohana. I followed the docs on their respective sites and even copied a couple of examples (changing tables/fields as needed), and still nothing. I’m not sure if it’s just me but Kohana’s ORM find_all function does not seem to work at all. The only result I got was “Resource id #31”. Googling both frameworks for some insight brought me no definitive solution. I worked for nearly 3 hours on each to get a complete controller functioning, and only got as far as the C and the U.

On the other hand, using CI + DataMapper, I had a complete controller with all functions – C, R, U, and D – ready to go in less than an hour, including time to reference the DM manual.

I was also less than impressed with Cake’s atrocious loading times. I loaded the same controller from each framework, and my results were CI: 0.348, Kohana 0.83, and Cake 3.29. That means on my (admittedly lower-spec) server, it took 10x as long for Cake to load as CI! I’d hate to see the load times when the entire app was up and running :-\

I guess for now I’ll be sticking with CI + DM. If Kohana can get their ORM library fully functional I’d give them a try again; I will admit that I felt Kohana was more flexible in certain areas and allowed a bit more fine-tuning, as well as having some features that CI doesn’t (Auth, Payment modules).

forum update part deux

I am more or less finished with the first draft of the forum. The nuts and bolts of the program are there (not highly polished but that’s what second/third/fourth drafts are for), and I am feeling pretty good about things.

Originally I was going to use a simple, hard-coded usergroup method to handle permissions for the forums. However, when I wanted to start adding permissions such as ability to view profiles, users online, ips, etc, it became a LOT harder to use the simple, hard-coded method. So I ended up creating somewhat of an ACL (access control list) for usergroups, which is working out pretty nicely. I combined the ACL (which is stored in the database) with some database caching to cut down on queries and it seems to work pretty well.

So far the hardest part has been syncing everything to work correctly — updating thread reply numbers when a post is created or removed, for example. You look over everything before testing it out and there’s (almost always) one little glitch that managed to sneak in there. So you fix it, then go back and reset the database (because apparently your program felt he was being a nice chap by updating what it could) and try again.

I am now on to rewrite #1. I am going to try my hand with Object Relational Mapping this time. I am hoping it will help speed up the CRUD-writing and make maintenance way easier — 2 things that ORM seems to offer, from all the research I’ve done. For anyone who is interested, I’ll be using DataMapper.

So – here I go! 🙂

here's a story, part 2

Yesterday I was bored and reading through some old entries here. I came across “Here’s a story” and remembered what happened the day after I got a date to junior prom, and the true reason he is my “What if Guy”…

A good friend of mine whom I went to school with had been hired and worked with me in housekeeping. We usually carpooled to work on the weekends, and she was friends with Randy, also (she’d heard me talk about him all the time
at school) and would sit with him and me after having a cigarette during break.

On this particular day — which was a few months after I started crushing on him — she came back in and sat with us. Apropo of nothing, she looked at me and said “I heard you got a date to Prom.”

“Yeah, I asked [shithead name redacted] and he said yes,” I replied. I glanced at Randy, who had this look on his face… you know, I can’t really describe it. It wasn’t something cliche like he’d been punched. It was more like a total ‘WTF???’ kind of look.

As my friend and I talked a little more about Prom I kept looking at Randy, who’d become quiet (even though he’d been talking with me quite a bit a few minutes earlier). Eventually  he excused himself and went to the men’s employee lounge. We didn’t talk much that day and it wasn’t until I got home that it came slamming home to me:


But (stupid stupid me) thought that it was too late to do anything about it; I’d already asked someone else and they accepted. I started dating this other guy after prom and by summer Randy had quit the hospital to go work at [store].

It could be that I totally misinterpreted the look on his face that day. It could be that he thought of me as nothing more than one of his nice co-workers and nothing more.  I know he had a girlfriend while we worked together; as to whether they were still together by prom time, I don’t remember and neither to my diaries.  We never did anything outside of work.  I don’t know for certain that there were any reciprocated feelings on his end. I don’t know that I’m the reason he quit working at the hosptial; he certainly had other logical reasons for getting a job at [store] — it was closer, probably paid a bit more, and (chances are) people didn’t treat him like shit there like some of the bitches we worked with at the hospital did.

I just remember that look.


While working on the remove_user function, I have a variable entitled $thread. I need to find the number of rows for the $thread query, and without thinking labeled that one $thread_count. 😀 The kind of humor you would probably only appreciate if you buy your own sheets.

Forum Update

Well, I’ve been working on my forum for a week now, and so far this is what I have done:

  1. Create/Modify/Close/Open/Delete Categories/Forums with per-forum permissions for each usergroup
  2. Create/Modify/Ban/Unban/Delete Users
  3. User Registration & Login
  4. Create New Thread
  5. Modify/Move/Delete Thread (for those with sufficient permissions)
  6. Reply with BBCode and Smilies
  7. Quick Reply with BBCode
  8. Modify/Delete/Restore Posts
  9. Integrated Smarty with Layout Capabilites

Phew! It’s kind of nice to see that I actually did get a lot done; truthfully I keep wondering if I’m wasting my time with this when there’s so many other forum scripts out there that have a team of people behind them.

Another neat thing I did was port CI’s form helper functions to Smarty functions so I can use things like

{form_open url="controller/function" id=$id}
(The id is if I’m modifying something; it appends the id to the action url)
{form_input name="field_name" value="submitted_value" default="default_field_value" extra="usually_css_here"}

If anyone is interested in having a copy, let me know in the comments and I’ll attach the functions I have. Currently includes form_open,form_close,form_dropdown,form_input,form_hidden. In addition, I ported the anchor and link_tag helper functions.

There’s still so much to do I wonder if I’ll get it done. I’m pleased with the progress so far, and if nothing else I am learning a lot 😀