Archive for July, 2008

19Jul

When I first started using CakePHP I was stuck for about 3 to 4 days with associations. After scouring the web, reading probably about 100 articles I have realized they are quite confusing when you first start with out using cake. I am hoping this post assists other people who were in my position for the past 3 days.

Associations are used for those tasks where you need to look up a row or multiple rows in another table based on an id number of sorts. The first thing to do in CakePHP is to make sure you have all the conventions correct to the very last point. If you want to make it really easy on yourself also I would recommend following their database naming conventions also. Here is a mini checklist:

  • Model file names, var $name, and class names are singular
  • Controller class names and var $name are plural also the file name is the plural version of model name followed by _controller.php
  • The folder name for a view is plural and the file name should match the “action” name or function name in the controller followed with the extension .thtml
  • Every table in your database should be the plural form of the model name.
  • The primary key of each table should be id
  • The associated key should be the name of another table singularly followed by _id (eg. I have a table named event_catogires, then in events my associated column name should be called event_category_id)

As far I can think right now. I think that may be all the key ones. If you have all the above correct the rest should be a breeze. I will now show you how I got something like a category name to appear next to a title of an article. This example isn’t meant to be copied. I don’t give enough information for that, but I hope this leads you guys in the right direction.

The Model:

class Event extends AppModel
{
var $name = 'Event';
var $useTable = 'events';
var $belongsTo = array('GalleryCategory' , 'EventCategory');

}

We are saying Event $belongsTo or $hasOne of each of these models (‘GalleryCategory’ , ‘EventCategory’). When find is called in the controller it will look up the following models and bring up that single row we are looking for in each of these.

The Controller:

class EventsController extends AppController
{
var $name = 'Events';

function index()
{
$this->set('events', $this->Event->findAll());
$this->set('title', 'All Events');
}
}

Now I won’t show the view because it doesn’t really matter. You could just enable scaffolding if you had wished. $this->set(‘events’, $this->Event->findAll()); set up a variable named events so that in the view we can retrieve an array with all database fields. This includes the rows that were found set up in the belongs to of the events model. You will need to make a model and controller for every related table.

On the reverse side. Let us say you wanted to show all events with a event_category. Then all you need to do is simply use the following line rather than belongsTo:

var $hasMany = 'Events';

There are other associations, but I feel that these 2 would be the most used. For example if you had something like tags which unlike categories have and belong to many pages you would use: var $hasAndBelongsToMany = ‘Events’;.

The most import thing to get this stuff to work is following the conventions. If you don’t everything falls to pieces somethings work, somethings don’t and you will have holes in your system.

If you have any questions feel free to post a comment. I am a beginner with cake myself, but I am hoping by the end of august I will be a pro haha.

Share/Save
14Jul

I am writing this post for one of my friends who was trying to decide what he needed to make his own computer. I decided I would help him out, and also help everyone who has this same question. Below I will list out some parts:

  • Case
  • Motherboard
  • Processor
  • Memory (Ram)
  • Power Supply
  • Extra Fans/Cooling
  • Hard Drive
  • Optical Drives
  • Video Card (if wanted, but is a very common add-on with most systems)

Now this is the very basic of any system. I included video card in there because, although it is an add-on, many people who make their own computers will buy a video card since the main factor is power at an affordable rate and this is needed for high end games.

So you have some options with everything. My best advice is to go to www.newegg.com, and read the user reviews before buying anything. Let us start with the case. A case is not just to have a pretty exterior. In fact if you are on a budget you would most likely want a very plain case. Many cases also come with power supplies and many come with fans. If you are trying to build a custom machine that has very high end specs you may want to steer clear of all in one solutions for your case since the power supply may not be enough to handle everything. I would recommend buying a case under 70 dollars. If you are really on a budget I would say somewhere from $30-$50 dollars.

Now the motherboard is a whole different beast. This part and the power supply are the most dependent on the knowledge of what you need. To select a motherboard you should be aware of what type of processor you want and what type of video card you need. If your motherboard doesn’t support them there is no way you will be able to make the processor or the video card fit on the board. In recent years there have been many many on board device attached to mother board including a NIC card, integrated video, usb, audio, etc. In past you would need to buy these all separately. If you are on a budget you may want to consider buying a motherboard that many features built into it especially if you aren’t playing high end video games.

The processor is the brain of your computer. Now a days you definitely at least want a dual core processor. I currently have a core 2 quad in my computer and that ran about $300.00 back in September of 07. It is a beast but I really doubt I have ever used more than 2 cores, which is a disappointment. The speed and amount of cores is really dependent on what sort of applications you are running. I wouldn’t doubt that my good ol’ quad core has hit about $200.00 at this point so if you are running music editing, video editing, photo editing, some high end games the quad core might be right up your alley. Why not buy it? We know that in the future people will take advantage of it. If you are on a budget then get a dual core processor under a $100.00 that has a good review. Also if you buy an Intel processor I would also recommend getting a new heat sink fan (the fan that comes with the processor, also known as HSF) because it is very loud and very obnoxious.

Ram is the most overestimated part of the computer. People think that to speed up their computer they need to through more ram. Well this is not the case obviously because all of those who have done so will tell you the performance increase is usually negligible. Ram is useful for editing software, video games and increased multitasking. The idea is the more you can rely on your ram, the less you need to rely on your (in comparison) slow hard drive to store page files. Speed is important here, but to be honest just get any decently fast ram that will fit in the motherboard. If you are running vista don’t even think about getting less than 2gb.

A power supply… This is pretty straight forward. Just see how much power you need from all your devices add it up and then get a power supply according to that. Also consider that you may need so more power for future cards or devices you may add. My current Power Supply Unit (PSU) is 700 watts.

Drives: Hard Drives and Optical Drives are a dime a dozen. Get whatever you want. The only thing I should mention is that if you are getting a scsi hard drive and want windows XP make sure to also buy a disk drive so that you can load the Intel Hard Drive Matrix drives (or something along those lines) while you install XP or else XP will not recognize the hard drive. You also need to set some other things up in your bios. I wen through this grief on my laptop. I just played with the settings in my bios related to my hard drive type and the loaded the drivers via F6 as the windows installer started.

Video Cards, well this is the part of the computer that people would call their baby. Do whatever you can here. Video cards are expensive, and you may want to get the cheapest one now that will work with all games currently out at medium to high settings, but in about a year won’t work with newer games past medium on the video settings. You may also consider buying the most expensive one which will last on higher settings for about 2-3 years before requiring an upgrade. Then again there is such a thing called SLI now. SLI lets you install 2 or more video cards (some motherboards have quad SLI now apparently) and run them at the same time to increase performance.

Now since we have all this amazingly awesome stuff consuming a ton of our world’s awesome resources we need to consider this will cause a ton of heat and chances are if you are running SLI, quad core, 4GB of ram you will need some extra cooling. There a few options which include liquid cooling and fans. I’ve never messed with liquid cooling, but I want to start playing with it. I heard that you need a water line running into your computer, but that is not confirmed. It is more difficult to set up liquid cooling, but the reduction in sound is amazing! The biggest thing here for me is sound. I hate extremely loud computers.

Recommendations: Now that you have an awesome computer DON’T RUIN IT!!! You know for a fact this computer is fast, and it runs extremely well so you have excuse. Don’t install tons of random software from the internet and if you do make sure to delete it after you are no longer using it. Also run Spy Bot Search and Destroy. Make it your best friend. It is very nice. Anti-virus is good, but in this day and age i feel it is a little unneccisary and I feel like it is a little too hyped up.

Also you may want to consider getting a few hard drives for different purposes. If you get multiple hard drives and use one to store media then chances are it won’t be damaged during a hard drive crash. You could do the same with all your programs that way if XP, Vista or some other OS dies on you, you may just reinstall the operating system but have all your data and programs. Try formatting these hard drives to Fat 32 rather than NTSC so you can use them across many operating systems. Speaking of operating systems… At this point you may also wan’t to consider trying out Linux or Hackintosh!

If you have questions about any of this stuff or need more advice. Post a comment and I will get back to you for sure :).

2Jul

So I decided to make a very rough mix of a portion of one of the songs that the drummer for [noROBOT] recorded lately. Here you can hear the same audio 3 different ways. 1 with everything going including the diy subkick, another without our diy subkick, then yet another with only the diy subkick. Tell me what you guys think. The diy subkick here is adding that extra umph, you will notice that the version with no diy subkick is lacking that power. Then again if your speakers are not designed to hear that frequency you won’t notice a difference at all. I recommend headphones. If you play the subkick only track and you hear nothing, that means your speakers can’t handle those sounds for sure. By the way this was a somewhat poor eq job. It was quick and dirty. ENJOY! I am calling it the diy subkick hopefully to cover me against any sort of trademark infringement. I am not sure if Yamaha coined the term Subkick or not. Also if you missed the first post about the subkick click here: http://www.parrisstudios.com/?p=3