Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Doh004
Apr 22, 2007

Mmmmm Donuts...

alucinor posted:

.htaccess question:

Another website has screwed up a potentially high-traffic link to my site. They've accidentally(?) appended a tracking code onto the URL so users who click their link to us end up at http://example.com/?&tokenid=fbb7e521-21da-4db2-97eb instead of at our homepage, http://example.com. So they end up at a page not found error instead of at our homepage.

I figured the easiest fix would be to use RedirectMatch in my .htaccess file to point users accessing that URL to the correct homepage:
code:
RedirectMatch ^?&tokenid=fbb7e521-21da-4db2-97eb [url]http://example.com[/url]
However, it doesn't work. Through googling I found and tried a couple of different methods (escaping the special characters, using Rewrite Rule to remove the query string, using Rewrite Rule instead), none of which worked for me. Any guidance or tips on what I'm overlooking?
I think something like this would work? It's just off the top of my head and I don't have time to test it out here.
code:
RedirectMatch ^?&tokenid=[0-9a-z\-] [url]http://example.com[/url]

Adbot
ADBOT LOVES YOU

geonetix
Mar 6, 2011


It's rather odd that a parameter like that in the request causes your site to throw a 404. I'd check that out first. Second, I don't know for sure, but isn't this more valid for rewriting:

code:
RewriteRule ^/?&token.... / [R]

alucinor
May 21, 2003



Taco Defender

Doh004 posted:

I think something like this would work? It's just off the top of my head and I don't have time to test it out here.
code:
RedirectMatch ^?&tokenid=[0-9a-z\-] http://example.com

Thanks so much, I really appreciate it. Sadly this gives me an Internal Server Error. This (note the leading slash after the carat):

code:
RedirectMatch ^/?&tokenid=[0-9a-z\-] http://example.com
Does not give an error, but also doesn't work.

What about matching ANY incoming URL containing "tokenid" anywhere in the URL? Looking at my analytics data, I see tokenid urls followed by a few different alphanumeric strings, but my site doesn't use "tokenid" so they all must from the same referrer. I tried:

code:
RewriteCond %{REQUEST_URI} tokenid
RewriteRule .* http://example.com [R]
No dice.

geonetix posted:

It's rather odd that a parameter like that in the request causes your site to throw a 404. I'd check that out first. Second, I don't know for sure, but isn't this more valid for rewriting:

code:
RewriteRule ^/?&token.... / [R]

No kidding. We're using a 10 year old proprietary custom CMS which is no longer supported by the developers. Only about 8 more months till we upgrade!

Tried this variant, still nothing.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Try this for the condition:

code:
RewriteCond %{QUERY_STRING} tokenid=([a-z0-9\-]+)
Maybe?

revmoo
May 25, 2006

#basta
Also are rewrites working at all? You should have AllowOverride set to all in httpd.conf for that site for .htaccess files to even work.

alucinor
May 21, 2003



Taco Defender

revmoo posted:

Also are rewrites working at all? You should have AllowOverride set to all in httpd.conf for that site for .htaccess files to even work.

Definitely working. I have a dozen other rewrites and scores of redirects, and I even checked to make sure there aren't any in conflict with this one.

Doh004 posted:

Try this for the condition:

code:
RewriteCond %{QUERY_STRING} tokenid=([a-z0-9\-]+)
Maybe?

Nope.

Thanks to all, at least I feel better that I didn't miss some really stupid obvious solution. :unsmith: I'm gonna poke around in the site code, maybe this CMS does use tokenid somewhere, that would explain why I can't rewrite it without it throwing the internal server error.

Edit: Ok wait, just realized that google analytics is showing hits on

example.com/?tokenid=fbb7e521-21da-4db2-97eb

note the missing & before tokenid.

Does that change anything?

alucinor fucked around with this message at 18:13 on Jun 4, 2012

DarkLotus
Sep 30, 2001

Lithium Hosting
Personal, Reseller & VPS Hosting
30-day no risk Free Trial &
90-days Money Back Guarantee!

alucinor posted:

Edit: Ok wait, just realized that google analytics is showing hits on

example.com/?tokenid=fbb7e521-21da-4db2-97eb

note the missing & before tokenid.

Does that change anything?
The first item in the query string is always preceded by a ?. I'm guessing the referring site wrote the query string wrong but Google is picking it up properly.

Edit:
Why not just do this in the root of the site that is being referred to:
php:
<?php
//index.php
if ($_GET['tokenid'] == 'fbb7e521-21da-4db2-97eb') {
    header('Location: http://www.example.com');
    exit;
}
?>

http://dev.mylha.com/rewrite/?&tokenid=fbb7e521-21da-4db2-97eb

DarkLotus fucked around with this message at 19:01 on Jun 4, 2012

Doh004
Apr 22, 2007

Mmmmm Donuts...
Edit* ^^^^
Do that

alucinor posted:

Edit: Ok wait, just realized that google analytics is showing hits on

example.com/?tokenid=fbb7e521-21da-4db2-97eb

note the missing & before tokenid.

Does that change anything?
Try my first suggestion sans ampersand.

Also, here's how I handle query strings for my app:

code:
RewriteCond %{QUERY_STRING} msg=([a-z]+)
RewriteRule ^([a-z]+)$ /index.php?page=$1&msg=%2 [NC,QSA,L]

alucinor
May 21, 2003



Taco Defender

DarkLotus posted:

The first item in the query string is always preceded by a ?. I'm guessing the referring site wrote the query string wrong but Google is picking it up properly.

Edit:
Why not just do this in the root of the site that is being referred to:
php:
<?php
//index.php
if ($_GET['tokenid'] == 'fbb7e521-21da-4db2-97eb') {
    header('Location: [url]http://www.example.com[/url]');
    exit;
}
?>

http://dev.mylha.com/rewrite/?&tokenid=fbb7e521-21da-4db2-97eb

That works! Sorta. Now I see the homepage content instead of the 404 page, but the site is not delivering the homepage template (home page has a sidebar menu, internal pages do not).

Close enough. Hate this CMS so much. Thank you again!

Sab669
Sep 24, 2009

Anyone know anything about this book? I just saw it advertised here and wasn't sure if it was goon-written.

My group decided to do our senior project in PHP, even though none of us are good in PHP so I figured some summer literature couldn't hurt for classes next quarter.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
I have a bit of a best practice question. I'm writing a model that will obviously have multiple ways of fetching the same data (Users for example can be fetched byId, byUsername, byEmail etc). Obviously this means each of those methods will need to fetch the same database fields, package them into the User class and then return that class instance. This opens up potential for lots of code repetition.

I'm not explaining myself very well, I can tell already, so I'll give an example:

php:
<?
class User
{
    ...

    public static function byId($id)
    {
        $CI = get_instance();
        $CI->db->select('us.user_id, us.user_name, us.user_email');
        $CI->db->where('us.user_id', $id);
        $r = $CI->db->get('user us');

        return new User($r->result());
    }

    public static function byEmail($email)
    {
        $CI = get_instance();
        $CI->db->select('us.user_id, us.user_name, us.user_email');
        $CI->db->where('us.user_email', $email);
        $r = $CI->db->get('user us');

        return new User($r->result());
    }

    ...
}
?>
In the above example, how can I save myself repeating the field names in every method? What is the best practice approach to this - if there is one? I've considered setting an array of field names and using that each time, but as I want to call these methods in a static context, that's not really a viable option.

(By the way, I'm using CodeIgniter if you hadn't guessed).

Edit: Also, bonus question! I have a User class wherein one of the properties represents the user's favourite AFL team. This property is called team and holds a Team object. Now, every time I want to get a User out of the database, I'd like to get their favourite team as well, so I can create the Team object and set it against the 'team' property for that User.

Obviously I will also have a Team model and there will be other models as well that will need to have a "Team" as one or more of the class properties. Obviously I can just include the team details in the query, get it all out and once and set it all up how I want it. But say a few months down the track I want to add an extra field to the Team table. Now I have a hundred different places where I'm fetching Team details that I need to update to also fetch the new field. How do I prevent this being an issue?

Help!

putin is a cunt fucked around with this message at 11:33 on Jun 5, 2012

musclecoder
Oct 23, 2006

I'm all about meeting girls. I'm all about meeting guys.
You could use the __call() magic method, something along the lines of:

php:
<?php

class User
{

    public function __call($method$argv)
    {
        $field strtolower(str_replace('by'''$method));

        // Maybe do some other logic to convert camelCase to unix_case.
        // So, byUserId would become user_id

        $db->where(sprintf('us.%s'$filed), $argv[0]);

        // Fill in the rest here
        return(new User($r->result()));
    }

}

Even better, you should put that in an abstract generic Entity or Model class and have all of your Entities/Models extend that. Can probably use return(new self($r->result())); in a generic __call() method.

I don't know enough about CI to help you with your second question, but you should look into using a real ORM that can handle cross references like that.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

musclecoder posted:

You could use the __call() magic method, something along the lines of:

php:
<?
// code removed for brevity
?>
Even better, you should put that in an abstract generic Entity or Model class and have all of your Entities/Models extend that. Can probably use return(new self($r->result())); in a generic __call() method.

I don't know enough about CI to help you with your second question, but you should look into using a real ORM that can handle cross references like that.

Unfortunately I'm not sure if this will solve the problem as I have some methods that will need to search on two criteria - byUsernameAndPassword() for example. Then I have queries that will be much more complex. Could I perhaps use a switch statement to build the appropriate 'where' statement depending on which method is run? For example:

php:
<?
class User
{
    public function __call($method, $argv)
    {
        $db->select(_FIELDS_GO_HERE_);

        switch ($method)
        {
            case 'byUsernameAndPassword':
                $db->where('us.user_name', $argv[0]);
                $db->where('us.user_pass', $argv[1]);
                break;
            case 'byId':
                $db->where('us.user_id', $argv[0]);
                break;
        }

        $db->get('user us');

        // etc etc
    }
}
?>
Is this a good way to do it? It seems like it might be hard to follow - a bit counterintuitive - for someone else reading the code. But maybe this is the only half-decent way to do it without significant code repetition? I think my main concern is that anyone looking to see what "User::byUsernameAndPassword()" does is going to expect to find that information in that function, but this approach puts the logic inside an entirely separate function.

putin is a cunt fucked around with this message at 13:31 on Jun 5, 2012

Black Noise
Jan 23, 2008

WHAT UP

I've got a database of zipcodes that are both 5 and 9 digit formats, is there a way to either reduce all of the zips to 5 digits?

I was looking into the substr function to allow for matching the first 5 digits and ignoring the last 4, I'd leave it as the 9 digit format but I don't think the people using this will know how to get their 9 digit zip.

Null Set
Nov 5, 2007

the dog represents disdain

Black Noise posted:

I've got a database of zipcodes that are both 5 and 9 digit formats, is there a way to either reduce all of the zips to 5 digits?

I was looking into the substr function to allow for matching the first 5 digits and ignoring the last 4, I'd leave it as the 9 digit format but I don't think the people using this will know how to get their 9 digit zip.

Do they have the dash in between the two parts of the code? If they do, you could do SUBSTRING_INDEX(fieldname, '-', 1) to get only the first part of the zip.

Black Noise
Jan 23, 2008

WHAT UP

Null Set posted:

Do they have the dash in between the two parts of the code? If they do, you could do SUBSTRING_INDEX(fieldname, '-', 1) to get only the first part of the zip.

nope just the numbers

Sab669
Sep 24, 2009

Black Noise posted:

I've got a database of zipcodes that are both 5 and 9 digit formats, is there a way to either reduce all of the zips to 5 digits?

I was looking into the substr function to allow for matching the first 5 digits and ignoring the last 4, I'd leave it as the 9 digit format but I don't think the people using this will know how to get their 9 digit zip.

Can't you just do something like

UPDATE zipcodes
set zipcode= (SELECT SUBSTRING(zipcode, 0, 5) FROM zipcodes)

Bear in mind I'm pretty bad at SQL :downs:

...Though now that I think about it that wouldn't work because the nested query returns > 1 result. Food for thought, though!

Null Set
Nov 5, 2007

the dog represents disdain

Sab669 posted:

Can't you just do something like

UPDATE zipcodes
set zipcode= (SELECT SUBSTRING(zipcode, 0, 5) FROM zipcodes)

Bear in mind I'm pretty bad at SQL :downs:

...Though now that I think about it that wouldn't work because the nested query returns > 1 result. Food for thought, though!

SQL code:
UPDATE zipcodes SET zipcode = SUBSTRING(zipcode, 0,5) WHERE CHAR_LENGTH(zipcode) > 5

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Sab669 posted:

Can't you just do something like

UPDATE zipcodes
set zipcode= (SELECT SUBSTRING(zipcode, 0, 5) FROM zipcodes)

Bear in mind I'm pretty bad at SQL :downs:

...Though now that I think about it that wouldn't work because the nested query returns > 1 result. Food for thought, though!

SQL code:
UPDATE
zipcodes

SET
zipcode = SUBSTRING(zipcode, 0, 5)
Should work - I think?

Edit: beaten!

putin is a cunt fucked around with this message at 16:03 on Jun 5, 2012

Doh004
Apr 22, 2007

Mmmmm Donuts...

Black Noise posted:

I've got a database of zipcodes that are both 5 and 9 digit formats, is there a way to either reduce all of the zips to 5 digits?

I was looking into the substr function to allow for matching the first 5 digits and ignoring the last 4, I'd leave it as the 9 digit format but I don't think the people using this will know how to get their 9 digit zip.

If it's MySQL then do this:

SQL code:
SELECT *
FROM ziptable
WHERE SUBSTR(zip FROM 1 FOR 5 ) = '11201' # or whatever zip you're checking

mewse
May 2, 2006

Black Noise posted:

I've got a database of zipcodes that are both 5 and 9 digit formats, is there a way to either reduce all of the zips to 5 digits?

I was looking into the substr function to allow for matching the first 5 digits and ignoring the last 4, I'd leave it as the 9 digit format but I don't think the people using this will know how to get their 9 digit zip.

For your database query you can select zipcodes that are LIKE '12345%'

KuruMonkey
Jul 23, 2004

Black Noise posted:

I've got a database of zipcodes that are both 5 and 9 digit formats, is there a way to either reduce all of the zips to 5 digits?

I was looking into the substr function to allow for matching the first 5 digits and ignoring the last 4, I'd leave it as the 9 digit format but I don't think the people using this will know how to get their 9 digit zip.

Please define your problem better; start with, are you wanting to update the DB, or to perform a re-presentation step on the data after a read from the DB? (as in leave the actual data alone, but always make a common format before working on the data in PHP?)

are the zip codes stored as integers or strings? do you want them as integers or strings?

in any case, in PHP the core of your answer is going to be substr($zip, 0, 5)
with varying amounts of intval() and strval() around the place, depending on the input and output types you want.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

KuruMonkey posted:

are the zip codes stored as integers or strings? do you want them as integers or strings?

FWIW: US zip codes can start with zero. They should never ever be treated as or stored as integers.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Gnack posted:

Unfortunately I'm not sure if this will solve the problem as I have some methods that will need to search on two criteria - byUsernameAndPassword() for example. Then I have queries that will be much more complex. Could I perhaps use a switch statement to build the appropriate 'where' statement depending on which method is run? For example:

php:
<?
class User
{
    public function __call($method, $argv)
    {
        $db->select(_FIELDS_GO_HERE_);

        switch ($method)
        {
            case 'byUsernameAndPassword':
                $db->where('us.user_name', $argv[0]);
                $db->where('us.user_pass', $argv[1]);
                break;
            case 'byId':
                $db->where('us.user_id', $argv[0]);
                break;
        }

        $db->get('user us');

        // etc etc
    }
}
?>
Is this a good way to do it? It seems like it might be hard to follow - a bit counterintuitive - for someone else reading the code. But maybe this is the only half-decent way to do it without significant code repetition? I think my main concern is that anyone looking to see what "User::byUsernameAndPassword()" does is going to expect to find that information in that function, but this approach puts the logic inside an entirely separate function.

I wouldn't do it like that. I would go with multiple constructors:

code:
$someUser = new User($username, $password);

$anotherUser = new User($id);
Basically then your username/password constructor would simply figure out what the user id is, then it would call the User($id) constructor to load up the rest of the information.

Black Noise
Jan 23, 2008

WHAT UP

Null Set posted:

SQL code:
UPDATE zipcodes SET zipcode = SUBSTRING(zipcode, 0,5) WHERE CHAR_LENGTH(zipcode) > 5

That did it thanks

Actually that ended up just deleting everything that is more than 5 characters, now the stranger thing is that when I set it to start after the 5th number it deletes the first 4 numbers

Black Noise fucked around with this message at 20:15 on Jun 5, 2012

Sab669
Sep 24, 2009

Now this is a bit of a work around, but what if you just did a select with the substring, exported those results to a CSV, then threw the CSV in there over all the existing values.

From the sounds of things, it sounds like this is a "one-time-only" problem and you'd need not to do it again.

musclecoder
Oct 23, 2006

I'm all about meeting girls. I'm all about meeting guys.

fletcher posted:

I wouldn't do it like that. I would go with multiple constructors:

code:
$someUser = new User($username, $password);

$anotherUser = new User($id);
Basically then your username/password constructor would simply figure out what the user id is, then it would call the User($id) constructor to load up the rest of the information.

The book Effective Java touches on this a bit and suggests you have multiple static constructors. Thus, User::byUsernameAndPassword() or User::byId(). You get the benefit of having a more expressive method name as well.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Black Noise posted:

That did it thanks

Actually that ended up just deleting everything that is more than 5 characters, now the stranger thing is that when I set it to start after the 5th number it deletes the first 4 numbers

Use what I posted before. It seems the mysql substring is weird:

SQL code:
UPDATE ziptable
SET zipcode = SUBSTR(zipcode FROM 1 FOR 5 )
This will go through every zip (even ones that are only 5 long) and "resize" them. If they don't need resizing, then nothing will happen to them.

Don't ask me why the index is starting at 1 like that, but when I was testing this on my own tables I had to do that to start at the root. It's probably somewhere in the MySQL docs, but :effort:

*edit* Also, if you're ever unsure of what an update/delete query will do, test it out with SELECT's first to make sure you're doing what you wanna do.

KuruMonkey
Jul 23, 2004

McGlockenshire posted:

FWIW: US zip codes can start with zero. They should never ever be treated as or stored as integers.

Shows what a Brit knows about zip codes!

Looks like the chap is actually looking for an SQL answer anyway...

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

fletcher posted:

I wouldn't do it like that. I would go with multiple constructors:

code:
$someUser = new User($username, $password);

$anotherUser = new User($id);
Basically then your username/password constructor would simply figure out what the user id is, then it would call the User($id) constructor to load up the rest of the information.

Hmm I see - the thing is, I want it to work more like musclecoder suggested and have static methods I can use to return User instances that match the parameters. The only real problem I'm having with that is where on earth do I put the list of field names so I'm not having to retype it every time? Can I access properties statically (does that even make sense)?

Peanut and the Gang
Aug 24, 2009

by exmarx

Gnack posted:

Hmm I see - the thing is, I want it to work more like musclecoder suggested and have static methods I can use to return User instances that match the parameters. The only real problem I'm having with that is where on earth do I put the list of field names so I'm not having to retype it every time? Can I access properties statically (does that even make sense)?

With codeigniter you can add this as the top of the class. (This is more like your original approach)
public static $selectStr = 'us.user_id, us.user_name, us.user_email';
then do
$this->db->select(self::$selectStr);

or make it a constant. or maybe a method named _setSelectStr() or whatever. It doesn't really matter.

But I'd be hesitant to do __call() in CI, because of how it works. And things like new User() wont work out with it because you're not supposed to do that with CI since it binds models to $this->modelName->methodName()

Also, I'm pretty sure you should be doing class User extends CI_Model {. That'll give you access to $this->db without having to call get_instance() all the time.

revmoo
May 25, 2006

#basta
Didn't they change to Model from CI_Model in 2.x?

Gimbal_Machine
May 11, 2005
Bite me euler angles.
Looking for a little advice:

I am working mostly on Android these days its been a while since i've written server side code that wasn't Java/Ruby. My small startup (about 8 developers) users PHP and Cake for our web services stuff. I saw some of the tutorials in the first post, but was wondering if anyway had a leaping off point for someone with a solid development background to get into php.

Something like http://www.ruby-doc.org/docs/ProgrammingRuby/ but for PHP?

Sidenote: Is Cake as bad as the OP suggests? These guys seem to be dedicated to its continued use (hence me learning php vs. trying to convert to something else).

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

barbarianbob posted:

With codeigniter you can add this as the top of the class. (This is more like your original approach)
public static $selectStr = 'us.user_id, us.user_name, us.user_email';
then do
$this->db->select(self::$selectStr);

or make it a constant. or maybe a method named _setSelectStr() or whatever. It doesn't really matter.

But I'd be hesitant to do __call() in CI, because of how it works. And things like new User() wont work out with it because you're not supposed to do that with CI since it binds models to $this->modelName->methodName()

Also, I'm pretty sure you should be doing class User extends CI_Model {. That'll give you access to $this->db without having to call get_instance() all the time.
Yeah I've been extending CI_Model for the longest time and I've come to the conclusion that I really don't like the way CI handles models. In my mind (and I thought this was a fairly common position, but maybe it isn't) a model should represent a single object of a particular type. It seems to me as though CI_Models are really object factories, rather than models. For that reason I'm going to take a shot at abandoning the CI_Models altogether and write my own. I'm yet to find out whether it will work well or not.

If I can keep the select list in a static property then maybe that will solve my problem. Thanks for the tip, I'll give it a go.

As a disclaimer for the above - I have no formal education in OOP, everything I know has just been picked up along the way from using C++ and Java. That means I'm happy for people to point out any mistakes I'm making in terminology because some of the correct terms for things I'm not exactly clear on.

revmoo posted:

Didn't they change to Model from CI_Model in 2.x?
Other way around - they moved from 'Model' to 'CI_Model' in 2.x.

putin is a cunt fucked around with this message at 01:43 on Jun 6, 2012

UxP
Aug 27, 2007

Gimbal_Machine posted:


[...] its been a while since i've written server side code that wasn't Java/Ruby.

If by Ruby you mean Rails (MVC + ActiveRecord), then you know enough of the basics of Cake to get by (at least 1.2/1.3, I've yet to touch 2.x). Yes, the internals aren't the most amazing code ever written, but it's got strong support at it's base. Extensions/plugins to it aren't the most available, unlike Ruby and Gems. My opinion is it isn't bad to use. My only huge complaint about it as a user was it's decision to toss around associative arrays instead of objects. It takes a bit to get used to, in any language.

Talking about PHP in general, read the language reference for a start. http://www.php.net/manual/en/langref.php PHP isn't hard, and it's docs aren't all that bad, given you search by keywords from Google.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
PHP's documentation is a weird thing - it's frustrating and tedious to find what you want, until you eventually learn their 'way' of doing things and then it becomes some of the simplest and comprehensive documentation I've ever read.

Sab669
Sep 24, 2009

Gnack posted:

PHP's documentation is a weird thing - it's frustrating and tedious to find what you want, until you eventually learn their 'way' of doing things and then it becomes some of the simplest and comprehensive documentation I've ever read.

Given I don't do much php, but I've never been let down by Googling "PHP <what I want to do>" and having their documentation be the first or second result, usually with what I want.

Master Stur
Jun 13, 2008

chasin' tail
Alright I'm feeling really stupid here. I installed aptana and wamp to use as a preview server, under run config I have everything pointing to where the project is stored and yet I always get "generic server doesn't support start".

I have no issues manually typing the /localhost/blah/blah.php and getting that to work, I just have no clue how to get aptana to preview it automatically. This is the first time I've ever messed with php or aptana :saddowns:

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

My problem with PHP's documentation is that it's not always immediately clear what version it's referring to, or even how performance intensive a certain recommendation might be. Check the coding horrors thread for more examples of how the 'default' implementations often are not the best ones.

Adbot
ADBOT LOVES YOU

First Time Caller
Nov 1, 2004

The key to reading the PHP documentation is to just sit and read the first couple paragraphs of the page FOR COMPREHENSION and not be a tard who immediately scrolls to the examples at the bottom of the page.

I can't tell you how annoyed I am by junior developers at my job who do that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply