Re: [PHP-DB] MySQL Conditional Trigger
You could try with the <> operator. !=, <>Not equal operator Or you could try it this way - ISNULL(col_or_data_to_check). Example: mysql> SELECT ISNULL(1+1); +-+ | ISNULL(1+1) | +-+ | 0 | +-+ 1 row in set (0.02 sec) Aleksander Chris wrote: Chris wrote: unknown compared to anything is unknown. he was talking about plsql and condition evaluation (ends with true or false), your point is absolutely useless. The context is in the database - my example is in the database. How is that useless? In case you missed it, this is the context: > Which only works when ShipDate was not NULL to begin with. > I suppose it evaluates the following to FALSE > IF NULL != '2008-10-31' AND '2008-10-31' IS NOT NULL THEN > (not liking the "NULL != '2008-10-31'" part) > > Please give me the correct syntax. > TIA > > anything compared to NULL is always false ie - you are wrong. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Copying an image from one server to another
How about sending the file via SCP? (it would be a much more safer to transfer files) -Aleksander Chris wrote: ioannes wrote: I am trying to: - check whether an image file exists on a server, - check whether it does not exist on another server, and if not exists - to copy from the first location to the second. I am using cURL. First step to capture the image from the first server. When I return this image to the browser I get a lot of strange characters. So has this captured the image and what do I use next to upload to the second server? I was trying to use file_exists and had problems referencing the file location as "http://.mysite.com/pic.jpg";. But I know I can also look at using readfile() and file_put_contents(), $fp = fopen(), fputs(), fpassthru() etc. What is best way? FTP. There's no way fopen is going to be able to write to a remote url, that'd just be such a huge security issue it's not funny. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?
It seems you missed my point :) if you would need all the data then select them all, but if you need only partial data from the table then you could limit yourself to that specific columns. I doubt everybody need everything all the time. True? Aleksandar Chris wrote: Aleksandar Vojnovic wrote: I would also suggest to limit yourself to things you actually need not to select the whole table. In this case you can't because you're looking for records that exist in one table that don't exist in another. Apart from looking at the whole table in each case how else would you do that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Re: the opposite of a join?
I would also suggest to limit yourself to things you actually need not to select the whole table. Aleksandar Jim Lucas wrote: Colin Guthrie wrote: Martin Marques wrote: SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts); Not ideal as has been mentioned else where in this thread. Col I think one would have to take into account the DB type being used here. I can have MySQL and PostgreSQL setup and running with the same table structure (well, as close as you can get) configured with two different databases in them. SQL #1SELECT* FROMcompany WHEREid NOT IN( SELECTcompanyID FROMcontacts ); SQL #2 SELECTcompany.* FROMcompany LEFT JOIN contacts ON( company.companyID = contacts.companyID ) WHEREcontacts.companyID IS NULL Now, both SQL statements will perform relatively the same on either DB's with a small data set. but, if you have a large data set, MySQL will benefit from having the Sub-Query style statement Where-as PostgreSQL will shine with the JOIN command. This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a year or so. But one problem that I have always ran into with MySQL is that when JOIN'ing tables that have large data sets is a PITA. So, if I was running MySQL, I would use SQL #1, but if I were using PostgreSQL, I would use SQL #2 If anybody else has suggestions or comments about performance between MySQL vs. PostgreSQL with regards to similarly formed SQL calls, I would like to hear their experiences. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with reading out value from urlline
Hi, you should do it like this - Aleksandar Ruprecht Helms wrote: Hi, I have the problem that a phpscript is not able to read out a value from the browserline. In the browserline I have the URL /?id=. The id-Value I want to process within the script but a echo $id shows me no value. The Php-Surrounding is very secured. Formfields and variables that schould be part of a mysqldatabase must be escaped by the mysql_real_escape_string-command. What is the right command to get the value from the browserline. Regards, Ruprecht -- Ruprecht Helms IT-Service & Softwaredevelopment Web: http://www.rheyn.de>Ruprecht Helms IT-Service & Softwareentwicklung, Loerrach -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
In addition to Chris's suggestions you should also alter the homeid column (set default to NULL and update the whole database which shouldn't be a problem) so you don't have to do a double check on the same column. I would also suggest that the TSCN_MEDIAid column should be an int not a varchar. Aleksander Chris wrote: Rob Adams wrote: select h.addr, h.city, h.county, h.state, h.zip, 'yes' as show_prop, h.askingprice, '' as year_built, h.rooms, h.baths, '' as apt, '' as lot, h.sqft, h.listdate, '' as date_sold, h.comments, h.mlsnum, r.agency, concat(r.fname, ' ', r.lname) as rname, r.phone as rphone, '' as remail, '' as status, '' as prop_type, ts.TSCNfile as picture, h.homeid as homeid, 'yes' as has_virt from ProductStatus ps, home h, realtor r, ProductBin pb left join TourScene ts on ts.TSCNtourId = pb.PBINid and ts.TSCN_MEDIAid = '3' where ps.PSTSstatus = 'posted' and pb.PBINid = PSTS_POid and h.id = pb.PBINid and h.listdate > DATE_SUB(NOW(), INTERVAL 2 YEAR) and (h.homeid is not null and h.homeid <> '') and r.realtorid = pb.PBIN_HALOid limit {l1}, {l2} Here is the query. I didn't know that it needed to have an ORDER clause in it for the limit to work properly. I'll probably order by h.listdate If you don't have an ORDER BY clause then you're going to get inconsistent results. The database will never guarantee returning results in a set order unless you tell it to by specifying an order by clause. To speed up your query, make sure you have indexes on: TourScene(TSCNtourId, TSCN_MEDIAid) ProductBin(PBINid, PBIN_HALOid) home(id, listdate) realtor(realtorid) If you can't get it fast, then post the EXPLAIN output. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Slooooow query in MySQL.
60k records shouldn't be a problem. Show us the query you're making and the table structure. OKi98 wrote: Rob Adams napsal(a): I have a query that I run using mysql that returns about 60,000 plus rows. It's been so large that I've just been testing it with a limit 0, 1 (ten thousand) on the query. That used to take about 10 minutes to run, including processing time in PHP which spits out xml from the query. I decided to chunk the query down into 1,000 row increments, and tried that. The script processed 10,000 rows in 23 seconds! I was amazed! But unfortunately it takes quite a bit longer than 6*23 to process the 60,000 rows that way (1,000 at a time). It takes almost 8 minutes. I can't figure out why it takes so long, or how to make it faster. The data for 60,000 rows is about 120mb, so I would prefer not to use a temporary table. Any other suggestions? This is probably more a db issue than a php issue, but I thought I'd try here first. 60k rows is not that much, I have tables with 500k rows and queries are running smoothly. Anyway we cannot help you if you do not post: 1. "show create table" 2. result of "explain query" 3. the query itself OKi98 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] weird comparsion
try comparing the type: if("0" === 0)echo 'Its not equal'; if(0 === 0)echo 'Its equal'; OKi98 wrote: Hello, Why does anything compared to 0 return true? I know it might seem to be a bit off-topic, but for me it is important for detecting if NULL value in table has been changed (for example NULL is changed to 0). if ("foo"==0) echo("foo equals to 0"); OKi98 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php