Jump to content

antmeeks

Members
  • Posts

    21
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

antmeeks's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've been stuck on this for a couple of hours now & I'd really appreciate some help(!) I have 2 tables: entries +----+--------+------+-------+------------+ ¦ id ¦ status ¦ type ¦ order ¦ date ¦ +----+--------+------+-------+------------+ ¦ 1 ¦ 1 ¦ term ¦ 4 ¦ 0000-00-00 ¦ ¦ 2 ¦ 0 ¦ item ¦ 6 ¦ 0000-00-00 ¦ ¦ 3 ¦ 1 ¦ term ¦ 1 ¦ 0000-00-00 ¦ ¦ 4 ¦ 1 ¦ term ¦ 7 ¦ 0000-00-00 ¦ ¦ 5 ¦ 0 ¦ item ¦ 5 ¦ 0000-00-00 ¦ ¦ 6 ¦ 1 ¦ term ¦ 8 ¦ 0000-00-00 ¦ ¦ 7 ¦ 1 ¦ term ¦ 3 ¦ 0000-00-00 ¦ ¦ 8 ¦ 0 ¦ item ¦ 2 ¦ 0000-00-00 ¦ +----+--------+------+-------+------------+ entry_text +----+----------+----------+---------+---------+ ¦ id ¦ entry_id ¦ language ¦ name ¦ value ¦ +----+----------+----------+---------+---------+ ¦ 1 ¦ 7 ¦ en ¦ title ¦ varchar ¦ ¦ 2 ¦ 7 ¦ en ¦ content ¦ varchar ¦ ¦ 3 ¦ 7 ¦ fr ¦ title ¦ varchar ¦ ¦ 4 ¦ 7 ¦ fr ¦ content ¦ varchar ¦ ¦ 5 ¦ 3 ¦ en ¦ title ¦ varchar ¦ ¦ 6 ¦ 3 ¦ en ¦ content ¦ varchar ¦ ¦ 7 ¦ 3 ¦ fr ¦ title ¦ varchar ¦ ¦ 8 ¦ 3 ¦ fr ¦ content ¦ varchar ¦ ¦ 9 ¦ 6 ¦ en ¦ title ¦ varchar ¦ ¦ 10 ¦ 6 ¦ en ¦ content ¦ varchar ¦ ¦ 11 ¦ 6 ¦ fr ¦ title ¦ varchar ¦ ¦ 12 ¦ 6 ¦ fr ¦ content ¦ varchar ¦ ¦ 13 ¦ 2 ¦ en ¦ title ¦ varchar ¦ ¦ 14 ¦ 2 ¦ en ¦ content ¦ varchar ¦ ¦ 15 ¦ 2 ¦ fr ¦ title ¦ varchar ¦ ¦ 16 ¦ 2 ¦ fr ¦ content ¦ varchar ¦ +----+----------+----------+---------+---------+ What I'm trying to do is some sort of join statement like: select * from entries where status = 1 and type = term join name,value from entry_text where entry_id = entries.id and language = en order by entries.order, entries.date ASC where I end up with an associative result, indexed by entries.id with the result from entry_text being a name/val pair nested array: array( [3] => array( [id] => 3 [status] => 1 [type] => term [order] => 1 [date] => 0000-00-00 [text] => array( [title] => varchar [content] => varchar ) ) [7] => array( [id] => 7 [status] => 1 [type] => term [order] => 3 [date] => 0000-00-00 [text] => array( [title] => varchar [content] => varchar ) ) [1] => array( [id] => 1 [status] => 1 [type] => term [order] => 4 [date] => 0000-00-00 [text] => array( [title] => varchar [content] => varchar ) ) etc... ) Doable...? (sorry for the wonky formatting - I can't get the editor to preserve my spacing)
  2. Yes, I have... And for my needs, that's like bringing a bulldozer to dig a flower bed... I'm really kinda looking for something more compact & straightforward... more along the lines of ezSQL (http://justinvincent.com/ezsql).
  3. I'm making the switch from years of using plain-jane 'deprecated' MySQL functions to PDO in a lot of my scripts. Consequently, I'm looking for a good, well-known & well-liked PDO wrapper / extension class. Something that automates some common db access functions (CRUD), handles try/catch/exceptions, and keeps track of metrics (query count, memory usage, etc.)... If anyone can point me in a direction, I'd really appreciate it!!
  4. I did have them organized in a separate files, but wanted to eliminate as many manual includes/requires as possible. Sigh... Yes, you are probably right - that's the best approach... I guess I was just trying to be too clever... I suspected it was dumb, which is why I posted it, lol.
  5. Lol, I knew that question would come up... I have two reasons for doing this: 1. To keep the functions organized in a meaningful way. 2. To load the files dynamically with spl_autoload_register().
  6. So I've decided to put several disparate but related functions into helper classes. Here's an example of what such a class would look like (with obviously more involved methods), and I'd like a critique on it's structure. class MyHelpers { public $str; public $Array; private $Params; public function __construct($method, $Params) { $method = '_' . $method; $this->Params = (is_array($Params)) ? $Params : NULL; $result = (method_exists($this, $method)) ? $this->$method() : NULL; (is_array($result)) ? $this->Array = $result : $this->str = $result; } private function _outputString() { if(is_array($this->Params)) : return (isset($this->Params['str'])) ? $this->Params['str'] : NULL; endif; } private function _makeArray() { if(is_array($this->Params)) : $str = (isset($this->Params['array'])) ? $this->Params['array'] : NULL; return explode(',', $str); endif; } } And here's how you would instantiate and use it: $GetResult = new MyHelpers('outputString', array('str'=>'This is a string.')); $str = $GetResult->str; $GetResult = new MyHelpers('makeArray', array('array'=>'1,2,3')); $Array = $GetResult->Array; Thoughts?
  7. You just need to write a recursive file finder/includer to traverse the subdirectories. There's a ton of them out there already written... just google it.
  8. Doh! I just figured that out right before your post.... You know it's getting late when you post in a forum before even trying it out first... What I wanted to do was nest the arrays into one var - which, as you say, my original post was a completely valid example of: $d=$Array3[$Array2[$Array1[$a]]]; Time for bed.
  9. Sorry, I guess I wasn't clear... I'm not trying to make a multidimensional array out of 3 other arrays, I'm trying to consolidate the compounding of multiple array key values into one variable. Literal from my example: variable '$b' = the value of array1's key that equals whatever is assigned to '$a': $b=$Array1[$a] variable '$c' = the value of array2's key named the value of variable '$b': $c=$Array2[$b] variable '$d' = the value of array3's key named the value of variable '$c': $d=$Array3[$c] So... is it possible to build up the value of var $d with one statement instead of 3?
  10. The most aesthetically pleasing thing is to keep all your scripting out of your html. You could do something like this: <script language="php">include('my_fantastic_script.php');</script> <html> <head> <title><?=$title?></title> <link rel="stylesheet" href="<?=$stylesheet?>" type="text/css" /> <script type="text/javascript" src="<?=$javascript?>"></script> </head> <body> <div id="wrapper"> <div id="left_col"> <h1><?=$h1_title?></h1> <?=$content?> </div> <div id="right_col"> <?=col_content?> </div> </div> </body> </html>
  11. These statements... $b=$Array1[$a]; $c=$Array2[$b]; $d=$Array3[$c]; combined into one statement like: $d=$Array3[$Array2[$Array1[$a]]] ??? I know my example isn't valid, but is it possible to do this kind of consolidation?
  12. If all your trying to do is pass a value from one page to the next, you should do that in a SESSION var, not POST and definitely not GET.
  13. This is why I hate Wordpress... it's promotion of spaghetti-style coding. Ugh, it hurts my eyes to see all that php inline with html.
  14. @ thorpe: I'm curious about Git... Can it integrate with Eclipse like Subversion?
×
×
  • 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.