8.25.2012

Installing New Server

Whoa hold the phone !  I must be nuts , In the middle of working on 4 (or 5 or 6?) websites I get a new computer and gotta put a clean OS on it.  So I'm gonna shoot for Windows Server 08.

So on to the first step.  Some bonehead set the admin password on the bios and forgot it - so open the case and remove the battery from the MB for a few seconds. Oh look - the master drive is in the slave position , so move it to sata0.  Eh, may as well put the wireless card in while I'm at it.

Bummer - gotta remove the power supply to install a card.  WOW this is a tight little box (LOL).  I gotta take the video card out to get to the battery - .  OK, one password erased - puttin it back together.

Whew, there's never enough plugs in a house. I had to go round up a six way.  Now for the test, turn it on and hope it don't blow up.

First I gotta go review the Server versions and seee which on best fits. (I'm thinking the one that does that virtual thingy.  Yup, Im going with server08 R2 - and after fighting stupid usb keyboard on boot - were installing. YAY !!!


Aight this sucks, stalls during setup - maybe its a crappy burn. Immma try a new disc and see how that works.

Hell yeah , nothin like a new burn to solve a problem. Almost there ------ Nopr not yetr.  I'll try foundation, I think it's a MB problem. Nope -  I took out the wireless network card - now its gonna run.

OH YEAH - but I only got licenses up to enterprise - so no data center edition - but the enterprise will be good. OK , had to force IRQ on wireless card - now i gotta download drivers . Nope still crashes , esp when installing drivers - no prob - a network cable is better anyway.

OK I played with that for a few - fun stuff but I gotta get busy - win7 ultimate it is.

Grr - my ultimate install was trashed - had to burn a new one of those too.

NONE OF THE ABOVE.

After a night and a day of fighting - it came down to ram test - the machine runs great after testing with only 1 mem stick at a time - viola - i need new ram. Yup, the wireless card is bad too - no prob - I got it running with a crossover cable through the laptop sahring wireless connection LOLZ.

Now to get all the dev software installed and running again.

WOW - transfer 40GB over 100mb connection still takes 50mins

11.15.2006

Eureka

Well...
I have been playing around with cake for about two weeks now and thought I would share this discovery. No it's not the next best internet application, but for the n00bs it will be quite helpful.

When creating pages(views) with forms and the controller functions that work with the view there are some interesting caveats. While the current cake documentation tries to explain how this works, I think it can be explained in more of a n00b way to understand.

Let's look at a simple Edit function. One of the things I struggled with early on was code re-use, and some of the extra code that sometimes goes with the theory. Well, the people at cakePHP have made all of our lives just a little easier. I like to try to use the same view and function for those parts of a web application that are redundant.

For example, our Add/Create and Edit function will use the exact same form 99% of the time. When you really think about it, sounds like carpel-tunnel to me. If you really want to take advantage of cake, learning how the current controller /view $this->data variable works will save you a ton of time. I'm not real keen on all the arrays as I am an object kind of guy, but that's not important right now.

Three functions are built right into cake that are great for watching the inner workings.
  1. core.php - set DEBUG to 2 ( let's you see the model at work running queries)
  2. the debug($var) function - it's like print_r only nicer
  3. pr($var) - works just like debug, it's a prettier print_r function
Sometimes during the scaffolding I like to use die(pr($var)) as well.

OK, let me get back on track here.

When you call your Add/Create function for the first time, there usually no variables involved. You are creating a new DB entry for whatever it is you are creating, be it Posts-Tags-Users; whatever.

The simplest function looks like this-

function Create(){

}


Then the create function calls the view-

<form>
<?php $html->input('Whatever/field'); ?>
</form>

Here is where the caveat comes into play. Make sure you follow the cake conventions
and CAPITALIZE the first leter of your Model name here. The $html form functions are meant to work in tandem with the Model.

OK, but what is so special about that you ask?
Well, I like to save time. Especially when it comes to redundant forms, so here is the tricky part. You are almost inevitably going to need an Edit function to go with that Add/Create function, so first off - redirect the function like so

function edit(){
$this->redirect('/yourcontroller/create');
}


then modify your create function to load the data you want to edit

function create($id = null){ // default null tells the function to use create mode vs. edit mode
if($id){ // if the $id var is set we are in edit mode
$this->data = $this->Whatever->find("id = $id"); // load the data we need to edit
}
// otherwise we are in create mode - do nothing
}


now when the view for the create function gets loaded $html->input('Whatever/field') will magically have the value="field data" filled in for you. All thanks to the controller variable $this->data.

11.13.2006

Things I know about CAKE (cakePHP that is), and thought I would share.

While working on a recent project using Cake, I had several Database tables that were to be running live. Any change made to the database had to be “approved” by a higher level administrator. So you see, even updating the changes in the active Database had to be stored in another place.

I decided to track the changes by creating a text field in the MasterChanges table. The text field is nothing more than a simple csv list of the columns from the Database table that an agent/sub user has made modifications to. There is another column that tells me which table to apply these changes to as well.

Once the MasterChangesController is told to “approve” an existing entry, the controller then dynamically loads the appropriate Models to update the respective tables. While there are about 20 active tables monitoring data, I figured that loading all 20 Models might be a bit memory intensive. Each time the administrator decides to approve certain entries, they may not necessarily need to load 20 Models.

Once the MasterChangesController reaches the stage where updating Database tables are necessary the following code works great.

$this->uses[] = ‘aNewModel’; // array_push() without the function call = COOL

$this->constructClasses(); // this is a cakePHP function in the Controller Class

While this particular piece of code is inside a foreach loop, the overhead required to load the Models like this is still less memory and processor intensive than loading all 20 Models at once. The caveat is, constructClasses() will only load those Models that have not been loaded yet, so when coming across an existing Model – the code simply skips right on past.

I am fairly new to cakePHP and this is my first project, so I am sure I will come across more great tricks to share in the future.