Tuesday, 15 March 2011

sql - Conditional limit in mySQL query possible? -


I am facing a decree about handling threaded comments in our project ... I have a simple All the comments which have the MySQL table There are two types: Parents and children children represent one answer to one parent or another child.

My problem:

- Comment (depth 0)
- Answer Children (Depth 1)
Answer to previous child Give (depth 2)
-Tiping (Depth 0)

Imagine the structure above and a MySQL query with my Linux 2. This is the last answer (depth 2) Actually I say something like this Would you like to try: Limit up to 2, if the child does not go to the next parent. Tried many questions with no luck ...

What I have just followed is as follows:
Select from SQL_CALC_FOUND_ROWS * Comments where comment_post_id = '{$ _REQUEST ["id "]} 'Comment_id by ORDER, comment_date DESC serious 10"

Important table fields are:
comment_id (index) | comment_parent_id (note of guardian or null is _ID) | comment_date

I'm very grateful

MySQL does not have any ideas!

< P> Work to parse structures like a tree. In the simplest scenario (the child's parent has an ID), you can revisit the program in an introductory manner to find all the sub-nodes in a given node. Maxwellwell wants to point you to the depth it decreases with each recurring call so that you end up with 0, which will stop the recurrence.

For example (Pseudo-code)

  findNodes (string par EntId, int maxLevel) (select from * positions, where parent = parent underwork (results ...) {if (maxLevel & gt; 0) {findNodes (result.nodeId, maxLevel-1)} doSomethingWIthAResult}} To do this in a more concise way, there are several techniques, all of which are indexed in some way The path in which the path of the current post is included, the path may look something like this: TopNode: Child1: Child2: Child3 ... in which you can do such a selection * Choose from the posts where the path like "TopNode%" and Depth = 2. 


Am I reinventing the wheel? PHP/Mysql User reigstration and payment processing -


I'm about a php / mysql platform code that does the following:

  • Admin panel
  • PayPal payment processing
  • Paypal subscription handling through the API so that the user should not have a PayPal account

Is anything like that before Exists from what I can use?

If nothing is like this, then I'm going to refresh it in the Zend Framework, which I have never done before. If I go this route, then I do not want to search for some parts of what I am doing?

EDIT: Certainly this should be posted first:

Why do I need this forum just a basis for me to create a PHP web-based business application For customers who have to use monthly subscription. I'm looking for something very lightly, it's the only platform to register and manage membership and payers, not on the entire website. It will not have a store in an Oscars meaning.

Integrate with an Object-Oriented PHP5 Framework Engineer from PayPal to Website Payment Pro API Easily To do DoDirectPayment, SetExpressCheckout, GetExpressCheckoutDetails and DoExpressCheckoutPayment in only 3 rows or less.


optimization - PostgreSQL: How to optimize my database for storing and querying a huge graph -


I am running PostGrace SQL 8.3 with 1. GHG RAM and 1.83 GHz Intel Core Duo Mac Mini with Mac OS X 10.5.8 . . I have stored a huge graph in my PostgreSQL database, which has 1.6 million nodes and 30 million edges. My database schema is similar:

  Make Table Nodes (ID Integer Primary Key, Title VARCHAR (256)); Create table edges (ID integer, link integer, primary key (id, link)); Create index id_idx current edges (ID); Create index link_idx Create edges;  

Data is visible in table edges

  ID link 1 234 1 88865 1 6 2 365 2 12 ...  

So it stores the ID for each node, which is the link to exit from id y.

The time to find all outgoing links is fine:

  = # Analyze select links from edges where id = 4620; Question Scheme ------------------------------------------------ --------------------------------- Index scan ID_idx on edges (cost = 0.00..101.61 rows = 3067 width = 4) (real time = 135.507..157.982 rows = 1052 loops = 1) Index Conduit: (id = 4620) Total runtime: 158.348 ms (3 lines)  

However, if I come Searching for links in the node, the database is 100 times slower (although the resulting number of incoming links is only 5-10 times the number of outgoing links):

  = #in Analyze identity ID from where the link = 4620; Question Scheme ------------------------------------------------ ---------------------------------- Heap scan on bitmap edges (cost = 846.31..100697.48 rows = 51016 width = 4) (real time = 322.584..48 9 83.478 lines = 26887 loop = 1) Check again: (link = 4620) - & gt; Bitmap index scan link_ idx (cost = 0.00..833.56 rows = width of 51016 = 0) (real time = 298.132..298.132 rows = 26887 loop = 1) Index link: (link = 4620) Total runtime: 49001.936 MS (5 lines ))  

I tried not to use PostGrace with a bitmap scan

  = # set_autm_mapscan = false;  

But the speed of the query for the incoming link did not improve:

  = # Select ID from the edges where the link = 1588; Question Scheme ------------------------------------------------ ------------------------------------------- Using link_idx on index edges Scanned (cost = 0.00.4.4777.63 rows = 1143 width = 4) (real time = 110.302..51275.822 rows = 43629 loop = 1) Index link: (link = 1588) Total runtime: 51300.041 ms (3 lines) < / Code> 

I have increased my shared buffers from 24MB to 512 MB, but this did not help, so I wonder if the outgoing and incoming links My query to show an asymmetric behavior of this kind? Is anything wrong with indexed my choice? Or would I want to make a node with an ID ID better by creating a third table for all incoming links? But this would be quite a waste of disk space. But since I'm new to SQL Database, maybe I'm missing something fundamental?

I think that's right.

You can use it after filling the table. Now the second query should be sharp, and should be slow down first.

To keep both questions fast, you must denormalize using a second table, as you have proposed. Just remember the cluster and analyze this second table after loading your data, so all the examples associated with the node will be physically grouped.

If you will not be able to ask it all the time and you do not want to store and back up this second table, you can make it temporarily before you can inquire:

  Create a temporary table eg_des_backwards as the link, from the order of the edges ID; Create index edges_backwards_link_idx on edges_backwards (link);  

You do not need to cluster this temporary table, because it will be ordered physically directly on creation. This does not make any sense for a query, but can help for many queries in one line.


Azure CTP signup -


I am trying to signup in the Ezore CTP but the whole process is looking for real non user friendly. This web page gives me a link to get a token, but when I click it does not appear to do anything it takes me to another page but I do not know whether the token was sent Or I have to do something else

On the Microsoft connect's dashboard, it tells me that what is my position in Ezur 'Participating', what does that mean? I am not participating because I do not have tokens. The whole process is very disappointing!

Is it possible to contact a real person?

It looks like you've already submitted a request for a token. I tried to sign up a week ago and I have not got anything yet. However, I have received my SQL Exxoor license and it is working well.

Besides, you are perfectly right, their website is messy and things are very difficult to understand. I hope they will clean it soon!

And I do not think they have any support setup.


How to handle script timeout error in classic ASP? -


In my classic ASP application, I am trying to generate web reports that are more than 7K and 14K records, but this "script timeout" error after 10 to 15 minutes

IIS setting is already The default value is more than that. And I have also written the following code in the personal page:

    

Please suggest me how to manage it.

You can not create an app that hangs up to 15 minutes by thread for HTTP requests Are there. It is destined for failure, no matter whether you should request a report to the people, prepare it in the background and inform the user that the report is still progressing / prepared by email or / or queue.

To support this, you will need to edit the user's registry:

This is not just a good design.


oop - Php abstract class site configuration -


I have a config class which is an abstract class. I want to set it so it automatically detects it That's what the server on the site and then assigns the appropriate constant. Let me line ten $ this-> hostName = $ _SERVER ['SERVER_NAME']; What is the correct way to do this rather than 'T_FUNCTION' and what is the better way to do it? Here is the first part of my class

  Abstract class config {public $ hostName; Public $ hostSlices; Public $ domain; Copy $ _SERVER ['SERVER_NAME']; // Exits "www" by the server name, but only then does it have the name $ -This-> Hostname = $ _SERVER ['SERVER_NAME']; $ This- & gt; Hostslites = Explosions (".", $ This-> Hostname); If ($ the-> hostSlices [0] == "www") {array_shift ($ this-> hostSlices);} $ this- & gt; Domain = join (".", $ This-> Hostslips); // Depending on the usage of this domain, different configuration setup is used. Switch ($ this- & gt; domain) {case "localhost": * / const HOST = "localhost"; // will http: // localhost / work also In that case, then this and SITE_ROOT can be the same variable and I can set them primarily on the basis of the host that the site is running Const. USER = "root"; Const. PWD = "xxxxxxx"; Const NAME = "hurunuitconz"; // database name // public $ name = "hello from config class"; // You can not access the variable from an abstract class, which you should define constants and then can be used anywhere #### ####### The location of the file groups ###### ## const SITE_ROOT = "http: // localhost"; Const ADMIN_IMAGES = 'http: // localhost / images / user_images / admin_images'; break; Case "charles.hughs.natcoll.net.nz": const HOST = "charles.hughs.natcoll.net.nz"; // will also be http: // localhost / work as well. In that case, then this and SITE_ROOT can be the same variable and I can set them primarily on the basis of that location on the site that the site is current Const USER = "Charles_Andrew"; Const. PWD = "xxxxxxx"; Const NAME = "charles_hurunuitconz"; // Database Name ########### Status of File Groups ######## const SITE_ROOT = "http://charles.hughs.natcoll.net.nz/ _Assignments/Indo/World "; // It is just the way natcoll confuses us in doing this. Const ADMIN_IMAGES = 'http://charles.hughs.natcoll.net.nz/_Assignments/Industry/www/images/user_images/admin_images'; break; }  

An abstract class should not allow you to set personal data (only one Heritage concrete square).

Also, take a look at the stack overflow for an interesting discussion on SERVER_NAME vs. HTTP_HOST

.

php - Preg matching and counting the resulting match in a short string -


I have a function that calculates the number of items in a string ($ paragraph) and tells me how many results There are letters, that is, spoon and spoon present 7, I can use it to complete the percentage of the string.

I need to reinforce it with preg_match because 10tsp should be calculated as 5.

$ letters = stellon ($ paragraph); $ Items = array ("toss", "tbsp", "tbs"); $ Count = 0; Calculate the number of formatting in foreign currency ($ item $ items) {// parameter $ countitems = substr_count ($ paragraph, $ item); $ Countlength = (strlen ($ item) * $ countitems); $ Count = $ count + $ countlength; } $ Composite = (($ 100 / $ character) * $ count);

I know that something like preg_match ('# [d] + [items] #', $ paragraph) will be something correct?

Sorry for the curve ball edit but there can be a place between numbers and $ items, can an example hold preg_match?

It's not quite clear to me that what you're trying to do with regex, but If you are just trying to match for a particular number-measurement combination, then it may help:

$ count = preg_match_all ('/ \ d + \ s * ( Tbsp | tsp | tbs) / ', $ paragraphs);

This will return the number of times, where a number-measurement combination occurs in the $ paragraph .

EDIT

  $ paragraph = "5tbsp and 10 teaspoons"; $ Charcnt = 0; $ Matches = array (); {Preg_match_all ('/ \ d + \ s * (tbsp | tsp | tbs) /', $ paragraph, $ matches) & gt; {foreach ($ matches [0] $ match) {$ charcnt + = Strlen (match $); }} Printf ("Total number of characters:% d \ n", $ charcnt);