Posts

Showing posts with the label PHP

Get "Null or Value" on related model in Yii

I have two tables, one with bases and one with transmitters. Bases work without transmitters, but transmitters don't work without bases. This means a HAS_MANY / BELONGS_TO relationship works out well in most cases. I recently ran into a two-fold problem. 1) I wasn't getting the null values from the related table when filtering on !=7. 2) If I added an OR statement, it ran really... really... really slow. The second was easily fixed by adding an index containing the joining field and the filtering field, but that still left the OR, which wasn't real efficient. The solution was coalesce in my search() function. $criteria->addCondition('coalesce(transmitters.field,0) != 7'); transmitters was the related table I was filtering on, and field was the field. Basically, anything that's null becomes a 0, so it's not a 7 (and not a null), so it shows up. Nothing too difficult this time, but hopefully it can save someone (probably me in a few weeks) s...

No longer in eCommerce

Since I'm no longer in eCommerce, I need a new blog title and about me text. Plus, since I'm developing stuff from scratch, I'm way more likely to write some code snippets on here. Time for some updates. Suggestions anyone?

HTTP 204 - the forgotten status

With everyone being so hot to use Ajax for things now, it seems that people forget how much simpler things can be done if you just stop and use some old-school techniques. I know I like Ajax for some things, but if it isn't necessary, then why introduce the extra bit of complexity? I'm speaking here about the 204 status code. Quoting the W3 204 No Content The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant. If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD ...

Easily Installing Perl, PHP, and Apache in Windows

Image
For many developers, running a simple web server on a windows box would simplify things a lot. I've been asked many times how to do that best. Well, my answer has been the same for a while now: use Indigo . Indigo Perl installs Apache as a service with PHP and Perl support. You can install this right to your Windows workstation and be off and running in a few minutes. No more uploading a file and saying "Oops" when there's a typo. Install it and view your site on your own PC before you FTP the files up to your web server. I've installed this on a few Windows servers as well for some Intranet apps. It sure beats manually configuring things to run Perl, since that's the language I program almost everything in. Yep, I'm old school, but that's mostly linked to my past as a Unix sysadmin. Wow... that makes me really old school.

My first bit of PHP

I actually did a quick PHP 301 redirect the other day on a server that I couldn't create an htaccess file on. Rather cool that php does that so easily. It has me inspired to learn more php with as easily as it actually worked (once I remembered to begin with I guess maybe this ol' dawg can learn new trix.