Jump to content

Xdega

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Xdega's Achievements

Member

Member (2/5)

0

Reputation

  1. So today I began looking in to Doctrine as a potential ORM/DBAL to get learning. The problem I found immediately, was the very poor documentation on the official website (vague 10 step checklist called a "tutorial"?). So this is basically two questions here: Are there any other ORM/DBAL out there that have a large userbase, and better documentation than Doctrine? (if so, what?) Basically want to examine my options in this area really. Is there any better third party documentation for Doctrine that could make the use and learning of doctrine more viable? I mean, I am only intended to test drive an ORM/DBAL w/ a personal blog website, so something pretty simple to start with. But I need something that I can pick up and roll with relatively easy, but that also has a large userbase and support system. Thanks. tl;dr, questions in bold.
  2. I c... I also discussed this with a friend of mine. I guess you raise some pretty clear points. It is pretty clear what they are trying to accomplish, I guess it makes perfect sense. (although my IDE hates it) I think it just appears counter-intuitive that there is an assignment, instead of a clear condition/comparison inside an IF It seems like potentially a way to ensure that the variable is being correctly initialized? I would assume that it would return false if any of the function calls fail? In which case an else {echo "error!" ;} could be used?
  3. I just want to know if this line of code is as messy as I am thinking. I think is is kinda odd from a logic perspective and I have never seen anything like it: <?php if ( $company_url = esc_url( get_post_meta( $post->ID, '_CompanyURL', true ) ) ) { //stuff here } ?> What are your thoughts on this? While I don't think it is critical to the functionality, what kind of revisions could/would/should be made to the above line of code?
  4. Ok. I went ahead and reformatted my code for the class file. Would this be considered clean code? Are there any other things that I would want to adjust? In terms of the functionality, it is doing exactly what I am intending atm. Thanks so much for the help thus far. <?php class PotentGate{ private $EndURL, $SourceURL = 'http'; private function GateSetURL(){ //The block below will ultimately reference a DB backend. //TODO: Implement a database layer to define the rerirect URL based on Source URL. if ($this->SourceURL=="http://foo/bar/misc.php"){ $this->EndURL="http://foo/bar/misc2.php?r=" . $this->SourceURL; } else { //no redirect defined } } public function GateGetURL(){ $this->GateSourceURL(); //aqcuire our source URL $this->GateSetURL(); //set our destination URL based on source return header('Location:' . $this->EndURL); //redirect } public function GateGetReferrer(){ $RefURL=$_GET['r']; if ($this->GateValidateURL($RefURL)){ return $RefURL; } else{ return 'Invalid/Undefined URL.'; } } private function GateSourceURL() { //TODO: Fix the $_SERVER['HTTPS'] below for https:// support. //if ($_SERVER['HTTPS'] == "on") {$this->sourceURL .= "s";} $this->SourceURL .= "://"; if ($_SERVER['SERVER_PORT'] != "80") { $this->SourceURL .= $_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']; } else { $this->SourceURL .= $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; } return $this->SourceURL; } private function GateValidateURL($URL) { $Pattern = "/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i"; return (bool)preg_match($Pattern, $URL); } }//end
  5. Yay It's working. Thanks for that, in terms of the formatting, I am a complete novice (as you can probably tell.), my apologies on that. I did go ahead and add the parens, but also noticed another blunder. I was using $this->Get_SourceURL, instead of $this->source URL /doh! I went ahead and reformatted my method names as such: GateSetURL() GateGetURL() GateSourceURL() Is this ok? Should I also Camel case my private members? $endURL, $sourceURL Also, any specific formatting advice you could share to help with my issue would be great. I am working on this project mostly solo atm, but it will be part of a larger project with some co-ed friends of mine (hence the reason I added the Gate prefix to my methods). So anything I can do to make the code cleaner, and to improve my development practices in general would be of great benefit. Thank you much for your help.
  6. So. I wrote this class that redirects a user to a new url: <?php class PotentGate{ private $endURL, $sourceURL = 'http'; private function Gate_setURL(){ //THE BLOCK BELOW WIL ULTIMATELY REFERECE A DATABASE BACKEND FOR DESTINATION URLS. if ($this->sourceURL=="http://blah.com/blah/misc.php"){$this->endURL="http://blah.com/blah/misc2.php?r=" . $this->Gate_sourceURL;} else {} } public function Gate_getURL(){ $this->Gate_sourceURL(); echo $this->sourceURL . "<br />"; $this->Gate_setURL(); //set our destination URL based on source echo $this->endURL . "<br />"; return header('Location:' . $this->endURL); //redirect } private function Gate_sourceURL() { //TODO: Fix the $_SERVER['HTTPS'] below for https:// support. //if ($_SERVER['HTTPS'] == "on") {$this->sourceURL .= "s";} $this->sourceURL .= "://"; if ($_SERVER['SERVER_PORT'] != "80") { $this->sourceURL .= $_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']; } else { $this->sourceURL .= $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; } return $this->sourceURL; } }//end It is implemented as such: <?php include("PotentGate.php"); $gate = new PotentGate(); $gate->Gate_getURL(); //IGNORE //function below will acquire get variable //echo "You came from:" . $gate->Gate_getReferrer(); ?> This works all well and good, as far as redirection goes, but refuses to add the $Gate_sourceURL to the end url. I am left with a url like: http://blah.com/blah/misc2.php?r= and what I am trying to achieve is that it assign $Gate_sourceURL to r (so I can use the source url as a value later on), as opposed to be being blank. ex. http://blah.com/blah/misc2.php?r=http://blah.com/blah/misc1.php Any Ideas?
  7. It will be a dynamic re-direct management via DB, that can control several websites via an eventual backend. Effectively turn them off, Shut them down etc, or otherwise just redirect their URLs to the developer homepage if there is an issue w/ the initial referral url. Basically to clarify, there will be a couple of lines at the top of a page. That will create an object and use the class to redirect the web-page appropriately. Of course it will not "always" redirect, most of the time it will not, it will just serve as a dynamic means to redir a websites traffic if need be.
  8. I understand the concept is not very difficult. What I am more concerned about, is if there are any performance caveats or subtleties I need to consider, in the presumption that this class could be used on a large scale (100s, 1000s or URLs). In other words, I want this to be as heavily optimized as possible. If there is not anything that needs to be considered in terms of the above, then fair enough. Just wanted to make sure. thx
  9. Ok. This one may be tricky to explain, but I will try. I am going to be looking at an idea for a PHP Class that can control the content of multiple websites via a DB. Basically, what it will do is use a database backend to set a "pointer url" that can be turned on or off for any hosted/connected domain in the database. This will be a system that can turn off potentially 100s of websites for "maintenance" or just disable inactive websites in an elegant manner (direct the url to the creator of the website). Here it is in bullet point form, to try and explain better: - User Visits a web page - A PHP class at the top of the page, queries the DB (hosted at the web developers end) -The user is directed to the appropriate url depending on the DB setting. -URLs that could be directed include the following (Maintenance, Website Inactive, Third-Party Redirect). NOTE: If a DB connection is unable to be made, then the website just loads as normal. (or die?) I am unsure where to start on the design of this, I am also concerned about any potential performance issues that may need to be accounted for? Anyone have any input from a design perspective on how to properly approach this?
  10. So I have this class: <?php class page { private $title; function __construct(){ //note: This code snippet (below) does not appear to be having the desired effect of //running the PHP code on page declared by p if(!isset($_GET['p'])) : include("../content/home.php"); else : include("../content/{$_GET['p']}.php"); endif; /////////////////////////////////////////////// } public function setTitle($t) { $this->title=$t; }?> and I need the following from the content page (the page declared by $_GET['p']) to be ran in the constructor: <?php global $page; $page->setTitle("About Us"); ?> this is in order to set the page title, so I can use it elsewhere. I hope my explanation (although fairly vague), is somewhat clear. Any help on this? I was told that using <<<EOF would be a potential requirement? but I am completely unfamiliar with that method.
  11. that is a pretty explicit parse error you are getting. What happens when you re-move the curly braces as the error suggests?
  12. Thank you so much for all of that information. I have definitely been told many a time that in programming concept is the most important thing. Although I have learnt that there is a lot of "shared syntax", for example I find assignment operators particularly interesting and they appear to be used in php, c++ and java in very similar syntactical forms. I am definitely getting a solid grasp for OO Programming, and very much love the way it works. Design patterns are something that I definitely need to study though I think. Anyways, thank you much for the information you provided. Once I can fully understand the pagination code (I NEVER copy/paste code unless I fully understand how it works and what it is doing), I should be able to use it in my rss/blog reader and it will likely be a class that I will use a LOT once I have it well written. I love pulling information from RSS feeds. I may even find myself creating my own RSS feeds from scratch, then pulling the feed in to blogs etc down the road. Then I am sure, once I learn a framework, there will be RSS reader classes that are written for me. As much as I like the idea of writing my own. I have had in interest in Symfony2 for a whille, I actually use the class_autoloader.php concept that SF2 uses to auto-load my classes in my own code. Maybe once I am a little more comfortable, I will buy a book on SF2 and play around with it. Thanks again for your insight. -Liam
  13. I agree Google is amazing. But hard to know what to search with regards to my very specific problem, and can't compare to direct discussion with someone who knows what they are talking about. (hope you don't mind) The MVC design pattern sounds like the kind of info I need to find. So in a nutshell basically the View and Controller are both put in to the index.php? One thing that worries me a little is the expandability to provide pagination support. Would this be more code that I would put in the View (alongside the foreach loop?) or would it be better practice to somehow separate the pagination system (as I could see pagination being a hefty amount of code to dump in the index.php). thx again. ps: I guess I could always cop out and show the latest 5 posts, then a url link to the original tumblr. As much as a pagination system would be nice to create, my level of expertise is very very novice ps2: I am looking forward to taking ProgrammingII (next semester) and study JAVA. I think it will be some great practice at OO Programming. Atm I am stuck with ProgrammingI which is basically procedural C++ (yuck!). I am thinking that my PHP skills will vastly improve once I have learnt a lot of JAVA.
  14. I see. Yeah. The problem I seem to be having the most... Is knowing how much code to put in the model(class), and how much to put in the presentation(index.php). My initial state of thinking is to have the class do most of the work, then create an object in the presentation(index.php) with a few parameters, to produce the result. Are there any resources on this particular topic that I can check out?
  15. I c. Interesting. One question though, Would you also suggest me moving the "echo" of the posts to the "view" instead of using my WritePost() method? Or does it not matter? this is the current client code (markup that I am using in my index.php) that I am using: <div class="blog_post"> <p><?php $post= new rss_reader("http://lhockley.tumblr.com/RSS"); $post->writePOST();?></p> </div> Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.