Re: [PHP] Node.PHP
Very nice! I'll have a proper look at this in the morning, and I'll try it out for myself. Looking forward to seeing more development on this. Michael On Thu, Mar 22, 2012 at 11:40 AM, Joseph Moniz wrote: > Hey, > > So i had my first Hackathon at work last week and my project was to > prototype making a node.js clone using PHP instead of V8. So i > snatched up libuv and joyent's HTTP parser and set off on a 24 hour > coding spree to get something workable. By the time the sun was coming > out the next morning the following code was working. > > > $http = new node_http(); > > $http->listen(8080, function($request, $response) { > $response->end("yay, super awesome response"); > }); > > nodephp_run(); > > ?> > > The C code that powers it was whipped together really fast and is kind > of hackish as a result. The code has some memory leaks that i haven't > had time to fully track down yet. Some small portions of the code were > borrowed from the phode project. > > In a naive benchmark on this simple server VS an equally simple server > in node.js this implementation already out performs node.js in > throughput by being able to serve just under 200% the amount of > requests per second that node.js could. Take that with a grain of salt > though because node.js has much more feature and is much more hardend > from production use. I do believe the PHP binary will have some major > performance gains over V8 as crossing the PHP <--> C barrier seems to > be a much lighter operation then crossing the V8 <--> C++ barrier. > > Any help or feedback will be greatly appreciated. The projects source > code can be found here: https://github.com/JosephMoniz/node.php > > - Joseph Moniz > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 2012-03-21, at 2:39 PM, Jay Blanchard wrote: > This is a continuation of the nested query thing I posted to the list a while > back. I was finally able to output a nested unordered array that worked out > well, but scope-creep has come in the door and I have to change gears. > > I have a project where I have multiple queries and each query uses the > results from the previous query to get it's results. I need to do one of two > things, either out put a multidimensional array that I can use json_encode() > on or I have to format the output from the queries as a JSON string. The > resulting JSON will be used by a JavaScript widget and must be formed > correctly. I created the following array by hand: > > $userList = array("John" => array( > "email" => "j...@demo.com", > "website" => "www.john.com", > "age" => "22", > "password" => "pass", > "description" => array( > "hair" => "blonde", > "eyes" => "blue", > "build" => "medium" > )), > "Anna" => array( > "email" => "a...@demo.com", > "website" => "www.anna.com", > "age" => "24", > "password" => "pass", > "description" => array( > "hair" => "brunette", > "eyes" => "hazel", > "build" => "petite" > ) > )); > > I ran it through json_encode() and got the following output > > {"John":{"email":"j...@demo.com","website":"www.john.com","age":"22","password":"pass","description":{"hair":"blonde","eyes":"blue","build":"medium"}},"Anna":{"email":"a...@demo.com","website":"www.anna.com","age":"24","password":"pass","description":{"hair":"brunette","eyes":"hazel","build":"petite"}}} > > jslint.com verifies this as good JSON (although I thought there had to be > square brackets around child arrays). > > If you were me would you just generate the JSON? If not what is he best way > to output an array that will nest properly for each subsequent query? > > Thanks for any insight! > > Would it not be easier to get the data from a view which has the tables joined? Then it would be one query and it's a simple matter to format the results into the multi dimensional array then json? Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think,
I've now fixed the iPad bugs in the menu component, and checked them on an iPad in a nearby apple store. Maybe it even works with iPhone now, if someone could check that for me I'd be much obliged.. If you're interested, http://mediabeez.ws and the download zip there are now updated with these latest improvements. Have a nice day.
Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think,
On Thu, Mar 22, 2012 at 1:01 PM, rene7705 wrote: > I've now fixed the iPad bugs in the menu component, and checked them on an > iPad in a nearby apple store. > Maybe it even works with iPhone now, if someone could check that for me > I'd be much obliged.. > > Oh, never mind to check on iPhone, that page is 2.5mb in size or so, and I'll just go to that apple store again to test it myself. Should've thought of that when I was there this morning ;) > If you're interested, http://mediabeez.ws and the download zip there are > now updated with these latest improvements. > > Have a nice day. > >
Re: [PHP] Thinking out loud - a continuation...
[snip] Would it not be easier to get the data from a view which has the tables joined? Then it would be one query and it's a simple matter to format the results into the multi dimensional array then json? [/snip] The data is all from one table. I'll write up a more thorough explanation in a little while. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On Mar 21, 2012, at 3:45 PM, Daniel Brown wrote: > >I would, yes, but that's not the point. Is Anna single? I'm > ready to trade Debs in for a newer model. > > -- > Ah... to be young again. But, on the other hand, they have so much to learn. :-) Cheers, tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
[snip] ...stuff... [/snip] Here is the explanation for what I have done and what I am trying to do - (based on the customer's request). A week or so ago I took a set of queries from one table and made them into an unordered list. This will be pseudo-code so that you get idea. SELECT DISTINCT column1 FROM table WHERE company = '1' while($column1 = mysql_fetch_array($query1results)){ SELECT DISTINCT column2 FROM table WHERE company = '1' AND column1 = $column1[0] while($column2 = mysql_fetch_array($query2results)){ SELECT DISTINCT column3 FROM table WHERE company = '1' AND column2 = $column2[0] } } This continues for up to 14 columns of data. I'm not worried about the recursive data retrieval, I have that part and like I said - I can output a nested unordered list from it quite handily. Now the customer wants JSON as the output. The JSON must reflect the children properly. So I have two choices, a multidimensional array that I can use json_encode() on or output a string that ultimately forms the JSON. We have all agreed that doing an array would be the best thing but I cannot wrap my head around it. If you have more questions fire away - I'd love to get this solved and off of my plate. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 12-03-22 11:28 AM, Jay Blanchard wrote: [snip] ...stuff... [/snip] Here is the explanation for what I have done and what I am trying to do - (based on the customer's request). A week or so ago I took a set of queries from one table and made them into an unordered list. This will be pseudo-code so that you get idea. SELECT DISTINCT column1 FROM table WHERE company = '1' while($column1 = mysql_fetch_array($query1results)){ SELECT DISTINCT column2 FROM table WHERE company = '1' AND column1 = $column1[0] while($column2 = mysql_fetch_array($query2results)){ SELECT DISTINCT column3 FROM table WHERE company = '1' AND column2 = $column2[0] } } This continues for up to 14 columns of data. I'm not worried about the recursive data retrieval, I have that part and like I said - I can output a nested unordered list from it quite handily. Now the customer wants JSON as the output. The JSON must reflect the children properly. So I have two choices, a multidimensional array that I can use json_encode() on or output a string that ultimately forms the JSON. We have all agreed that doing an array would be the best thing but I cannot wrap my head around it. If you have more questions fire away - I'd love to get this solved and off of my plate. Fix this code... I've come across codebases that did this specific type of nested querying and it resulted in 1 queries to the database on every page. Instead, create a layered approach: 1. Select your root elements. 2. Loop over in PHP and create an array of child IDs. 3. Select the children from the database. 4. Go to step 2. This way you will only every perform "depth" number of queries. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
[snip] Fix this code... I've come across codebases that did this specific type of nested querying and it resulted in 1 queries to the database on every page. Instead, create a layered approach: 1. Select your root elements. 2. Loop over in PHP and create an array of child IDs. 3. Select the children from the database. 4. Go to step 2. This way you will only every perform "depth" number of queries. [/snip] I see what you're saying but I don't know that this reduces the number of queries - it just handles them in a different order. How do I get to the output that I need? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 12-03-22 11:58 AM, Jay Blanchard wrote: [snip] Fix this code... I've come across codebases that did this specific type of nested querying and it resulted in 1 queries to the database on every page. Instead, create a layered approach: 1. Select your root elements. 2. Loop over in PHP and create an array of child IDs. 3. Select the children from the database. 4. Go to step 2. This way you will only every perform "depth" number of queries. [/snip] I see what you're saying but I don't know that this reduces the number of queries - it just handles them in a different order. How do I get to the output that I need? It definitely reduces the queries... your current method gets all the first level nodes in one query, then performs a query for every single parent node. Mine only performs a query for each level in the tree. If you have 5 nodes at the first level you will perform 6 queries. Mine will perform 2. To generate the nesting structure at each level you track the level members. Something like the following (untested pseudoish): Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 12-03-22 11:58 AM, Jay Blanchard wrote: [snip] Fix this code... I've come across codebases that did this specific type of nested querying and it resulted in 1 queries to the database on every page. Instead, create a layered approach: 1. Select your root elements. 2. Loop over in PHP and create an array of parent IDs. 3. Select the children from the database. 4. Go to step 2. This way you will only every perform "depth" number of queries. [/snip] I see what you're saying but I don't know that this reduces the number of queries - it just handles them in a different order. How do I get to the output that I need? Sorry, I just realized I didn't make the optimization explicitly obvious... when I say "Select the children" I mean to select them using an IN( id1, id2, id3 ) clause instead of a query for each. This is why we build the array of parent IDs (also I wrote build an array of "child IDs", it should have read "parent IDs" and has been fixed above :). Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
[snip] On 3/22/2012 11:17 AM, Robert Cummings wrote: On 12-03-22 11:58 AM, Jay Blanchard wrote: [snip] Fix this code... I've come across codebases that did this specific type of nested querying and it resulted in 1 queries to the database on every page. Instead, create a layered approach: 1. Select your root elements. 2. Loop over in PHP and create an array of child IDs. 3. Select the children from the database. 4. Go to step 2. This way you will only every perform "depth" number of queries. [/snip] I see what you're saying but I don't know that this reduces the number of queries - it just handles them in a different order. How do I get to the output that I need? It definitely reduces the queries... your current method gets all the first level nodes in one query, then performs a query for every single parent node. Mine only performs a query for each level in the tree. If you have 5 nodes at the first level you will perform 6 queries. Mine will perform 2. [/snip] How so? A query must be performed for each parent node to get its children. parent | childchildchildchild | grandchild grandchild [snip] To generate the nesting structure at each level you track the level members. Something like the following (untested pseudoish): [/snip] I'll try to apply this and see what I run into. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
[snip] Sorry, I just realized I didn't make the optimization explicitly obvious... when I say "Select the children" I mean to select them using an IN( id1, id2, id3 ) clause instead of a query for each. This is why we build the array of parent IDs (also I wrote build an array of "child IDs", it should have read "parent IDs" and has been fixed above :). [/snip] SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, id3) ? I am sure I am not following you now. Maybe I didn't explain clearly? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 12-03-22 12:34 PM, Jay Blanchard wrote: [snip] Sorry, I just realized I didn't make the optimization explicitly obvious... when I say "Select the children" I mean to select them using an IN( id1, id2, id3 ) clause instead of a query for each. This is why we build the array of parent IDs (also I wrote build an array of "child IDs", it should have read "parent IDs" and has been fixed above :). [/snip] SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, id3) ? I am sure I am not following you now. Maybe I didn't explain clearly? What's the field for which you are selecting data? I've written this up as a parent/child relationship but it works for data/sub-data relationships also. SELECT itemId, otherData FROM table WHERE "some condition"; SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...); Then just link up the sub-data to the primary data in a loop and finally generate your JSON. Does that clarify? Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 3/22/2012 11:40 AM, Robert Cummings wrote: On 12-03-22 12:34 PM, Jay Blanchard wrote: [snip] Sorry, I just realized I didn't make the optimization explicitly obvious... when I say "Select the children" I mean to select them using an IN( id1, id2, id3 ) clause instead of a query for each. This is why we build the array of parent IDs (also I wrote build an array of "child IDs", it should have read "parent IDs" and has been fixed above :). [/snip] SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, id3) ? I am sure I am not following you now. Maybe I didn't explain clearly? What's the field for which you are selecting data? I've written this up as a parent/child relationship but it works for data/sub-data relationships also. SELECT itemId, otherData FROM table WHERE "some condition"; SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...); Then just link up the sub-data to the primary data in a loop and finally generate your JSON. Does that clarify? [/snip] I must confess that the raging sinus headache and my general confusion makes this really unclear for me today. Maybe I should just set it aside for a day or so. I am super dense today. For each level I am selecting for each parent in the level above. Let's say that level 2 contains 8 people. Level 3 contains 14 people. Only some of the 14 belong to the 8 and must be associated properly. So how can I, with one query, associate level 3' 8th, 9th and 10th people with level 2's 6th person keeping in mind that the 9th person might also belong to level 2's 4th person. Just link up the sub-data? Place this array into a child array of the parent array? Again I apologize - maybe I should push away and let the customer know that it'll be a couple of more days. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
On 12-03-22 01:06 PM, Jay Blanchard wrote: On 3/22/2012 11:40 AM, Robert Cummings wrote: What's the field for which you are selecting data? I've written this up as a parent/child relationship but it works for data/sub-data relationships also. SELECT itemId, otherData FROM table WHERE "some condition"; SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...); Then just link up the sub-data to the primary data in a loop and finally generate your JSON. Does that clarify? [/snip] I must confess that the raging sinus headache and my general confusion makes this really unclear for me today. Maybe I should just set it aside for a day or so. I am super dense today. Rest might do you well on a number of levels :) For each level I am selecting for each parent in the level above. Let's say that level 2 contains 8 people. Level 3 contains 14 people. Only some of the 14 belong to the 8 and must be associated properly. So how can I, with one query, associate level 3' 8th, 9th and 10th people with level 2's 6th person keeping in mind that the 9th person might also belong to level 2's 4th person. At one point you indicated all the data was coming from one table. Can you send me the table fields and indicate which fields are used to determine parent child relationship? Also 2 sample rows of data which have a relationship would be helpful. Just link up the sub-data? Place this array into a child array of the parent array? Again I apologize - maybe I should push away and let the customer know that it'll be a couple of more days. Yeah... child array... 'children' :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thinking out loud - a continuation...
[snip] > At one point you indicated all the data was coming from one table. Can you > send me the table fields and indicate which fields are used to determine > parent child relationship? Also 2 sample rows of data which have a > relationship would be helpful. [/snip] Columns - tier1, tier2, tier3, tier4 etc. (ends with tier14) Children of tier1 are tier2 - select distinct tier2 from table where tier1 = "foo" and company = "1" select distinct tier2 from table where tier1 = "bar" and company = "1" etc. Children of tier2 are tier3, etc. tier1 tier2 tier3 1, executive, ceo,ceo 1, executive, vp-ops, vp-ops 1, executive, vp-admin, vp-admin mgr 1, executive, vp-admin, vp-admin ops mgr 1, executive, vp-admin, vp-admin mgr 1, executive, vp-admin, vp-admin clerk 1, professionalpro-mgr pro-admin 1, professionalpro-IT pro-dev 1, professionalpro-IT pro-infra 1, professionalpro-IT pro-dev 1, technician tech-admin tech-admin mgr 1, technician tech-opstech-ops mgr Thanks for all of your help. I know I am being a PITA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] set_error_handler() only triggering every Nth time
Resending since I didn't get a single reply. Maybe it got lost? -Original Message- Sent: Tuesday, March 13, 2012 5:58 PM I am implementing a custom error handler and started noticing some bizarre behavior. Every Nth time I refresh the page, I see the error/output. In my 'includes/common.inc.php' the key things are these: set_error_handler('php_error_handler'); function php_error_handler($errno, $errstr, ...) { //does some stuff //calls php_custom_error_log() } function php_custom_error_log() { echo "php_custom_error_log : ".date('H:i:s'); if ($error = error_get_last()) { var_dump(LOG_LEVEL, $error); //does more stuff } My test page: For those astute observers, you'll note that $empty is not an array and therefore I expect an error message (well warning) ( ! ) Warning: Invalid argument supplied for foreach() in /usr/home/vz/examples.videosz.com/error_handler_tests.php on line 20 Call Stack # TimeMemory FunctionLocation 1 0.0005 663616 {main}( ) ../error_handler_tests.php:0 As I simply click 'refresh' on the browser I noticed that it was only periodically working. I then deduced that it was directly related to the number of apache threads. So if I had 15 then it would work every 15th refresh: developer@vm:/usr/local/etc/apache22$ ps aux | grep httpd (standard input):39:root 15855 0.0 2.0 204156 20292 ?? Ss 28Feb12 1:33.48 /usr/local/sbin/httpd -k start (standard input):48:www 89522 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):49:www 89523 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):50:www 89524 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):51:www 89525 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):52:www 89527 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):53:www 89528 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):54:www 89529 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):55:www 89530 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):56:www 89531 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):57:www 89532 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):58:www 89533 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):59:www 89534 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):60:www 89535 0.0 2.0 204156 20332 ?? I 8:03PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):61:www 89563 0.0 2.1 206204 21700 ?? I 8:17PM 0:00.10 /usr/local/sbin/httpd -k start (standard input):62:www 89578 0.0 2.0 204156 20332 ?? I 8:22PM 0:00.01 /usr/local/sbin/httpd -k start (standard input):74:developer 89587 0.0 0.1 9092 1196 1 S+8:30PM 0:00.01 grep -inH --color httpd 124 125 StartServers 15 126 MinSpareServers 15 127 MaxSpareServers 20 128 ServerLimit 50 129 MaxClients50 130 MaxRequestsPerChild 15 131 KeepAlive Off 132 Just to check and the time is updating each press and every 15th try I'd get this: php_custom_error_log : 19:54:20 int 30711 array 'type' => int 8192 'message' => string 'Directive 'register_globals' is deprecated in PHP 5.3 and greater' (length=65) 'file' => string 'Unknown' (length=7) 'line' => int 0 When I'd expect to see a message every time (with a new timestamp). Then I REALLY looked at the 'message' part. "register_globals". WTF? That isn't the error I expected. Hmmm.. what happens if I move the second function inline to the first... BAM! EVERY TIME it works perfectly. So WTFF??! Why does moving it inline make any difference? All I suspect is the $error = error_get_last() part. For some reason that isn't consistent. And the other strange thing is that it's giving me erroneous error messages (well, we do have register_globals on, but that's not the error I was expecting). Then I did another test replacing the foreach() with this statement: require_once "/foo.inc.php"; A few bizarre things about this too. For starters why do I get TWO error messages. One WARNING from MY error handler and then a FATAL default PHP one?! Sorta defeats my purpose. WARNING: require_once(/foo.inc.php) [function.require-once]: failed to open stream: No such file or directory
[PHP] MySQL table design
Hello List, Is it possible to create a MySQL table with characters such as "." and "[]" in the column headers? If so would you explain how? Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL table design
On 23 Mar 2012, at 00:10, Chris Stinemetz wrote: > Is it possible to create a MySQL table with characters such as "." and > "[]" in the column headers? If so would you explain how? Try putting the column names in backticks (`). BUT... whatever the reason why you want to do that, IT'S WRONG. Seriously, don't do it. It will cause you more problems than you think it will solve, and I don't even know what problem you think it will solve. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL table design
On 2012-03-22, at 8:10 PM, Chris Stinemetz wrote: > Hello List, > > Is it possible to create a MySQL table with characters such as "." and > "[]" in the column headers? If so would you explain how? > > Thank you, > > Chris > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Periods are not allowed, nor other characters that are reflected in file paths. You can use the back tick to wrap the field names, but I really don't recommend it. If you ever need to port this to another DB, it might not be as forgiving Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL table design
On Thu, Mar 22, 2012 at 7:42 PM, Stuart Dallas wrote: > On 23 Mar 2012, at 00:10, Chris Stinemetz wrote: > >> Is it possible to create a MySQL table with characters such as "." and >> "[]" in the column headers? If so would you explain how? > > Try putting the column names in backticks (`). > > BUT... whatever the reason why you want to do that, IT'S WRONG. > > Seriously, don't do it. It will cause you more problems than you think it > will solve, and I don't even know what problem you think it will solve. > I am just trying to preserve the source headers from the original data I want to import into the table. Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL table design
Leave the past behind. You're moving forward. And - for whatever reason that they were used originally, you now have the opportunity to rid yourself of column names that must be a pia to type all the time. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP]make error
Hello, I have a problem. When I configure php with the parameter --with-mysql=/usr/local/mysql and make, some errors happen. Below is the errors: ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init' ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect' ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init' ... and so on. Is there someone also come across this? Can anyone help me? Thanks! -- 黄昭源 *Best Wishes To You!*
Re: [PHP] Thinking out loud - a continuation...
On 12-03-22 03:54 PM, Jay Blanchard wrote: [snip] At one point you indicated all the data was coming from one table. Can you send me the table fields and indicate which fields are used to determine parent child relationship? Also 2 sample rows of data which have a relationship would be helpful. [/snip] Columns - tier1, tier2, tier3, tier4 etc. (ends with tier14) Children of tier1 are tier2 - select distinct tier2 from table where tier1 = "foo" and company = "1" select distinct tier2 from table where tier1 = "bar" and company = "1" etc. Children of tier2 are tier3, etc. tier1 tier2 tier3 1, executive, ceo,ceo 1, executive, vp-ops, vp-ops 1, executive, vp-admin, vp-admin mgr 1, executive, vp-admin, vp-admin ops mgr 1, executive, vp-admin, vp-admin mgr 1, executive, vp-admin, vp-admin clerk 1, professionalpro-mgr pro-admin 1, professionalpro-IT pro-dev 1, professionalpro-IT pro-infra 1, professionalpro-IT pro-dev 1, technician tech-admin tech-admin mgr 1, technician tech-opstech-ops mgr Thanks for all of your help. I know I am being a PITA. Your data structure doesn't appear to be very ummm normalized... Nonetheless, the following should do it: query( $query ) ) { while( ($row = $db->fetchRow()) ) { $id = $row['id']; unset( $child ); $child = array ( 'id' => $id, 'parentId' => false, 'children' => array(); ); $root[$id] = &$child; $children[$id][] = &$child; } } // // Establish the nested levels. // for( $tier = 2; $tier <= 14; $tier++ ) { if( !($parents = &$children) ) { break; } $parentTier = $tier - 1; $parentIds = array(); foreach( array_keys( $parents ) as $parentId ) { $parentIds[$parentId] = $db->quote( $parentId ); } $query = "SELECT DISTINCT " ." tier{$tier} AS id, " ." tier{$parentTier} AS parentId " ."FROM " ." tiers " ."WHERE " ." company = {$company} " ." AND " ." tier{$parentTier} IN (".implode( ',', $parentIds ).") "; if( $db->query( $query ) ) { unset( $children ); $children = array(); while( ($row = $db->fetchRow()) ) { $id = $row['id']; $pid = $row['parentId']; unset( $child ); $child = array ( 'id' => $id, 'parentId' => $pid, 'children' => array(); ); $children[$id][] = &$child; foreach( $parents[$pid] as &$items ) { foreach( $items as &$item ) { $item['children'][$id] = &$child; } } } } } $json = JSON_encode( $root ); ?> Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] set_error_handler() only triggering every Nth time
On 12-03-22 03:57 PM, Daevid Vincent wrote: Resending since I didn't get a single reply. Maybe it got lost? -Original Message- Sent: Tuesday, March 13, 2012 5:58 PM I am implementing a custom error handler and started noticing some bizarre behavior. Every Nth time I refresh the page, I see the error/output. Have you tried sending headers that disable caching? Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php