[PHP] Re: im puzzled
SELECT uid FROM users WHERE uid NOT IN (SELECT uid FROM picks) HTH, James Potts "Jeremy Morano" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi , > > this is my query > > SELECT users.uid FROM users, picks WHERE users.uid = picks.user_id; > > this works correctly. The results are what they are supposed to be: > However, when I change the = sign to a <> or !=, The results are completely > incorrect. > > -- > > picks.user_id contains: 5, 1, 7, 8, 9, 12, 13, 15 > > users.uid contains: 1, 8, 9, 5, 7, 10, 11, 12, 13, 14, 15 > > > the result for SELECT users.uid FROM users, picks WHERE users.uid = > picks.user_id; is: > > 5, 1, 7, 8, 9, 12, 13, 15 > > and the result for SELECT users.uid FROM users, picks WHERE users.uid <> > picks.user_id; is: > > 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 7, 8, 9, 10, 11,12, 13, 14, 15, 1, 5, > 8, 9, 10 ,11...etc > > it goes on for 80 rows with no particular pattern..H.E.L.P.!. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Database Preference? -- Manuel, Michael, Miles
Manuel, Thanx for the excellent overview of metabase. I will give it a test drive. A couple further questions, if you have time: Do you execute meta commands like you do with the other db interface functions, e.g., odbc_connect(), odbc_select(), etc., or are you able to encapsulate SQL between tags, e.g. SELECT bar FROM foo WHERE barname = "chocolate"; Using a function set can be cumbersome, compared to embedded language interfaces where you just put SQL between tags, just like PHP is handled between the tags. Also, can you PREPARE, DECLARE, and OPEN cursors like, say, in Informix, so you can use variable SELECT parameters? For example, using Informix ESQL/C you can PREPARE a statement, use it to DECLARE a CURSOR, and the OPEN the CURSOR USING multiple values, as in: sprintf( query, "%s %s %s %s %s %s %s %s %s", "begin work;", "update account set balance = balance + ?," "where acct_number = ?;", "update teller set balance = balance + ?", "where teller_number = ?;", "update brance set balance = balance + ?", "where branch_number = ?;" "insert into history values (?, ?);", "commit work;" ); $prepare qid from $query; $execute qid using $delta, $acct_number, $delta, $teller_number, $delta, $branch_number, $timestamp, $values; I should be able to check metabase out later this evening. If it can handle the above native database language, I think it will be an asset, especially for some of our older applications. Thanx again, James Potts "Manuel Lemos" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello, > > James wrote: > > Regarding a database abstraction package: does Metabase handle all > > "standard" SQL constructs (as opposed to vendor-specific SQL extensions)? > > The GUI applications to be ported were built with JAM, which basically > > provides an abstraction layer via its JPL language. JPL has not been > > restrictive in terms of required functionality, nor was there any real > > performance hits. Can the same be said of Metabase? Also, would Metabase > > present a significant learning curve for experienced C and SQL programmers? > > > > I will download PostgreSQL and check it out. > > Metabase does much more than you probably may want. Basically you can > just submit any queries to the database server. Metabase doesn't touch > them. What it does is when you are composing your queries with constant > values, it may convert the respective data type values from a database > independent data type set to the target database data types. > > Let's say you have strings or date constant values. Each database may > have different ways to escape strings or format dates. Metabase provides > functions to do that translation if you want to use direct queries. I > you want to use prefered queries, with placeholders ( ? ) in the queries > that are replace with constant values when the queries are executed, the > functions to set those values perform the translations for you. > > For retrieving result data returned by SELECT queries, Metabase also > provides functions to translate the data to a database independent > format, so in your applications you only have to handle one universal > format that you do not need to adapt if you decide to switch to your > database backend. > > That is not all. Metabase also provides unique features, that are very > important for Web programming, all in a database independent way. One is > the ability to create and access to database sequence objects. Sequences > are objects that can generate sequential integer unique numbers. They > are often used to generate id values for table primary keys. Sequence > number generation is guaranteed to be atomic, so it is adequate for > environments where many users access the database concurrently, like the > Web. Sequences are implemented with real sequence objects in databases > that support it like Oracle and Postgres, but others that don't support > real sequence objects are emulated with tables with a single > auto-incremented integer field. > > Another important feature is the ability for Web programming is the > ability to limit the range of rows that are returned from a select > query, like MySQL LIMIT clause, but in a way that is supported by all > databases supported by Metabase. This is great to let you develop > applications that display query results split in multiple pages if they > have too many rows. > > Metabase is not also good for develop applications to access databases. > It is also able to install databases for
[PHP] Re: A Separate Process?
*** *** Function definitions *** * */ #ifdef SIGSTP #include #include #endif /* ignsigcld is nonzero to handle SIGCLDs so zombies don't clog the system */ void daemon_start( int ignsigcld ) { int nChildPID, fd ; strcpy( FUNC,"daemon_start") ; /* * If we were started by init (process 1) from the /etc/inittab * file there's no need to detach. This test is unreliable due * to an unavoidable ambiguity; if the process is started by * some other process and orphaned (parent terminates before * we are started) */ if (getppid() == 1) goto out ; /* * Ignore the terminal stop signals (BSD) */ #ifdef SIGTOU signal(SIGTOU, SIG_IGN) ; #endif #ifdef SIGTTIN signal(SIGTTIN, SIG_IGN) ; #endif #ifdef SIGTSTP signal(SIGTSTP, SIG_IGN) ; #endif /* * If we were not started in the backgroung, fork and let * the parent exit. This also guarantees the first child * is not a process group leader */ nChildPID = fork() ; if (nChildPID < 0) { LogError( "daemon: Can't fork first child", 0 ); exit(-1) ; } if (nChildPID > 0) exit(0); /* we are parent */ /* * First child process * Disassociate from controlling terminal and process group. * Ensure the process can't reacquire a new controlling terminal */ #ifdef SIGSTP /* BSD */ if (setpgrp(0, getpid()) == -1) { LogError( "daemon: Can't change process group (1)", 0 ); exit(-1) ; } if ((fd - open("/dev/tty", O_RDWR)) >= 0) { ioctl(fd, TIOCNOTTY, (char *)0) ; /* lose cont. tty */ close(fd) ; } #else /* System V */ if (setpgrp() == -1) { LogError( "daemon: Can't change process group (2)", 0 ) ; exit(-1) ; } signal(SIGHUP, SIG_IGN) ; /* immune from pgrp leader death */ if ((nChildPID = fork()) < 0) { LogError( "daemon: Can't fork second child", 0 ) ; exit(-1) ; } else if (nChildPID > 0) exit(0) ; /* first child */ #endif /* second child */ out: /* * close any open file descriptors */ for (fd = 0; fd < _NFILE; fd++) close(fd) ; errno = 0; /* probably set from EBADF from a close */ /* * Move the current directory to root to ensure not * in a mounted file system */ chdir("/") ; /* * clear inherited file creation mask */ umask(0) ; /* * See if the caller isn't interested in the exit status * of its children and doesn't want to have them become * zombies and clog up the system. With System V all we * need to do is ignorre the signal. With BSD, however, * we have to catch each signal and execute the wait3() * system call. */ if (ignsigcld) { #ifdef SIGSTP int sig_child() ; signal(SIGCLD, sig_child) ; #else signal(SIGCLD,SIG_IGN) ; #endif } } /* end daemon_start */ /* eof: daemon.c */ -- HTH, James Potts "Richard Lynch" <[EMAIL PROTECTED]> wrote in message 038001c13140$8e0bf1e0$6401a8c0@Lynchux100">news:038001c13140$8e0bf1e0$6401a8c0@Lynchux100... > You could just log the IP into a database, and then look it up later in > another script in a "cron" job. You'll need PHP installed as a stand-alone > binary (aka CGI) and you'll want to read: > > man 5 crontab > > You could use select distinct and then would only need to look up each IP > once for a user that viewed many pages. > > If you wait too long, though, the IPs will change on you for DHCP clients. > Still the same country probably though. > > To answer your original question :-) what you are talking about is called > "fork" (like a fork in the road) and you do it something not unlike this: > > exec("/path/to/some/other/script &", $results, $errorcode); > echo implode("\n", $results); > if ($errorcode){ > echo "OS Error: $errorcode. Usually path/permissions. man > errno\n"; > } > > It's the & symbol that tells the shell to fork. > > The other script in question has to, e, I forget exactly, but I think it > has to *NOT* bind up stdin, stdout, or stderr, because then Apache and PHP > are waiting for that output... > > Search the archives for "fork" and "&" and "exec" and you should find more > posts. > > -- > WARNING [EMAIL PROTECTED] address is an endangered species -- Use > [EMAIL PROTECTED] > Wanna help me out? Like Music? Buy a CD: http://l-i-e.co
Re: [PHP] Database Preference? -- Manuel, Michael, Miles
Manuel, Thanx again for your help. I will check it out this evening. Sounds like you're a busy man. ;-) Keep up the good work. James Potts "Manuel Lemos" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > James Potts wrote: > > > > Manuel, > > > > Thanx for the excellent overview of metabase. I will give it a test drive. > > A couple further questions, if you have time: > > > > Do you execute meta commands like you do with the other db interface > > functions, e.g., odbc_connect(), odbc_select(), etc., or are you able to > > encapsulate SQL between tags, e.g. > > > > > > SELECT bar FROM foo WHERE barname = "chocolate"; > > > > > > Using a function set can be cumbersome, compared to embedded language > > interfaces where you just put SQL between tags, just like PHP is handled > > between the tags. > > That is the subject of some other project that I have which is an actual > meta-language defined in XML. You write what you want to do with XML > tags, and there is a compiler that translates that in to code of a > target language, like PHP. This is not yet a released project although I > have given a talk on this in San Diego O'Reilly Open Source conference > in July, and if all goes well I will give another talk in November in > PHP conference in Frankfurt. More information on that is available here: > > http://www.meta-language.net/ > > > > Also, can you PREPARE, DECLARE, and OPEN cursors like, say, in Informix, so > > you can use variable SELECT parameters? For example, using Informix ESQL/C > > you can PREPARE a statement, use it to DECLARE a CURSOR, and the OPEN the > > CURSOR USING multiple values, as in: > > > > sprintf( query, "%s %s %s %s %s %s %s %s %s", > > "begin work;", > > "update account set balance = balance + ?," > > "where acct_number = ?;", > > "update teller set balance = balance + ?", > > "where teller_number = ?;", > > "update brance set balance = balance + ?", > > "where branch_number = ?;" > > "insert into history values (?, ?);", > > "commit work;" ); > > $prepare qid from $query; > > $execute qid using $delta, $acct_number, $delta, $teller_number, > > $delta, $branch_number, $timestamp, $values; > > Metabase supports prepared queries which you can execute as many times > as you want with different values, if it is that what you are asking. > > > > > I should be able to check metabase out later this evening. If it can handle > > the above native database language, I think it will be an asset, especially > > for some of our older applications. > > I am not sure if it is exactly what you are asking. In any case there is > an extensive manual and a tutorial that details all it can do. > > Regards, > Manuel Lemos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]