[PHP-DB] New Metabase Aniversary release

2002-01-21 Thread Manuel Lemos

Hello,

Finally I made time to put a new Metabase release together celebrating
the 2nd aniversary since its first public release which is also the 3rd
aniversary since I started developing it.

For this release I added new features that either were requested or
contributed:

- Query result bulk data fetching - There is now a set of functions that
let you query databases, collect results into single variables and free
the results in a single call. These functions were contributed by Lukas
Smith and Christopher Linn.

These functions are meant not only to reduce the number of Metabase API
calls necessary to perform common types of queries but also to optimize
the result set data retrieval process. This was introduced to overcome
some complaints that Metabase would not perform as fast as other PHP
database abstraction packages.

There is now a function that retrieves a single result set row and is
optimized for each of the supported types of database. Around this and
other functions there are now some new functions that let you retrieve
just the first field of the first row, just the first row, just the
first field of all rows and all the fields of all rows.

Additionally, these new functions may convert the data types of the data
that is retrieved if necessary by specifing a data type mapping array
before retrieving the query results. If no data type is necessary, for
instance with result sets with only text and integer fields, no
conversion is performed, thus providing full database portability when
necessary without compromising Metabase ability to retrieve result set
data at the highest speed.

- Customizable error handling - There is also now a function to specify
a error handling function. This is meant to please those that want to
provide custom error handling separately from their main database
programming code.

- SQL REPLACE abstraction - There is now a function that lets you
execute SQL REPLACE command like what MySQL provides, but in a way that
works with almost all databases. SQL REPLACE is non-standard SQL command
that is like SQL INSERT, except that instead of just inserting a new
row, first it figures if there is already a row with the same primary
key values. If such row exists, it just updates it with new values,
otherwise it inserts a new row. This is very good to add or update
entries to relationship tables that have as primary keys, the keys of
other two or more tables.

To implement this command, Metabase uses transactions with the databases
that support them, except for MySQL that has native support for SQL
REPLACE.

For this release it was not possible to already integrate the Sybase
driver that was contributed by Sergio Zia. It will be done in a next
release after it is properly tested with the Metabase driver conformance
test as it is the standard for Metabase to assure the quality of its
drivers by only releasing what has be throughly tested.

Since Metabase feature list is not stopping to grow, in a future release
I also want to split all these optional features in such way that each
programmer only loads what their scripts need avoiding further PHP
compilation overhead.

That is all for now. If you would like to have some feature in Metabase
please feel free to approach either by contributing with code or just
suggesting what you have in mind even if you feel that you don't have
the time or the skill to do it yourself.

Metabase is free Open Source package and can be found with full
documentation and tutorials here:
http://phpclasses.UpperDesign.com/browse.html/package/20

Regards,
Manuel Lemos

-- 
PHP Database 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-DB] query problem

2002-01-21 Thread Jason Wong

On Tuesday 22 January 2002 13:18, Sommai Fongnamthip wrote:

> Hi,
>   I have problem with these mysql's query:
>
>   select * from holder, management where holder.id=management.id or
> (holder.name=management.name and holder.surname=management.surname) order
> by holder.no
>
>   It take a long time (more than 1 minute) with thousand record.  I have
> index within 2 table (name+surname, id).  It did not have problem if I
> check only id or name+surname.

This is a mysql question. Perhaps you should ask on the mysql list.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
One expresses well the love he does not feel.
-- J.A. Karr
*/

-- 
PHP Database 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]




[PHP-DB] query problem

2002-01-21 Thread Sommai Fongnamthip

Hi,
I have problem with these mysql's query:

select * from holder, management where holder.id=management.id or 
(holder.name=management.name and holder.surname=management.surname) order 
by holder.no

It take a long time (more than 1 minute) with thousand record.  I have 
index within 2 table (name+surname, id).  It did not have problem if I 
check only id or name+surname.

SF


-- 
PHP Database 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-DB] Similar Articles or Customers also bought...

2002-01-21 Thread Jonathan Hilgeman

Technically, you should have a list of saved orders associated with a
customer ID. You should be able to search the saved orders for all customer
IDs that purchased the current product ID. Then, generate a giant list of
all products that all those customer IDs purchased, and compile them into a
big list, with the most common purchases at the top. You should then maybe
have an array looking like:

$Products["Product Name"] = Number Purchased;
-
$Products["PHP Programming Book"] = 24;
$Products["MySQL Programming Book"] = 22;
$Products["PC Magazine Subscription"] = 14;
$Products["Windows XP Pro"] = 6;
$Products["Anti-Fungal Loin Cream"] = 1;
-

Then, display any products that have more than X number of purchases. That
way, you truly have a valid "Customers That Bought This Also Bought These"
list. A bit intensive, maybe, but it works.

- Jonathan


-Original Message-
From: olinux [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 3:25 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Similar Articles or Customers also bought...


I am trying to figure a simple way of creating a
script for a news site to recommend articles that are
similar [i.e. about the same company]

Two examples are:
http://www.theroyalgazette.com/apps/pbcs.dll/artikkel?Avis=RG&Dato=20011218&;
Kategori=BUSINESS&Lopenr=112180020&Ref=AR
  (See the "Linked Articles")

and Amazon's "Customers who bought this book also
bought:" feature

I think it would work something like this 

TABLE 1
keyword_id | keywords

TABLE 2
url_id | url | url_title

TABLE 3 
id | keyword_id | url_id

this would be your basic search engine - for example
you could look up a keyword in table 1 using that
keyword_id get the url_id's that correspond and then
get the url's and titles for display.

I guess that the "similar srticles" feature would work
the same way by taking the current url_id lookup the
corresponding keyword_id's use those to query for
url_id's that match those keywords and then grab the
url and title for display.

Confused? I am :)

This seems like it would work, but seems too
intensive... Maybe a different table structure which
contains url_id | similar_url would be better?
then you could look up the current url_id for url_id's
of similar articles?

Thanks for your help.

olinux



__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
PHP Database 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]

-- 
PHP Database 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]




[PHP-DB] Similar Articles or Customers also bought...

2002-01-21 Thread olinux

I am trying to figure a simple way of creating a
script for a news site to recommend articles that are
similar [i.e. about the same company]

Two examples are:
http://www.theroyalgazette.com/apps/pbcs.dll/artikkel?Avis=RG&Dato=20011218&Kategori=BUSINESS&Lopenr=112180020&Ref=AR
  (See the "Linked Articles")

and Amazon's "Customers who bought this book also
bought:" feature

I think it would work something like this 

TABLE 1
keyword_id | keywords

TABLE 2
url_id | url | url_title

TABLE 3 
id | keyword_id | url_id

this would be your basic search engine - for example
you could look up a keyword in table 1 using that
keyword_id get the url_id's that correspond and then
get the url's and titles for display.

I guess that the "similar srticles" feature would work
the same way by taking the current url_id lookup the
corresponding keyword_id's use those to query for
url_id's that match those keywords and then grab the
url and title for display.

Confused? I am :)

This seems like it would work, but seems too
intensive... Maybe a different table structure which
contains url_id | similar_url would be better?
then you could look up the current url_id for url_id's
of similar articles?

Thanks for your help.

olinux



__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
PHP Database 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]




[PHP-DB] RE: MySQL Update help needed

2002-01-21 Thread Adam Royle

A few things to check:

1. You have a connection to the database (I'm assuming you do).
2. mysql_query() is a php function so you should not put a dollar sign
before it (indicating it is a variable. If you want mysql_query() to return
a variable, do something like this: $result = mysql_query("UPDATE etc");
3. Check that you field names are the same, they are case sensitive (I'm
pretty sure).
4. If all that doesn't work, try setting the query out in a logical pattern.
This way it is easy to find mistakes.

ie. $sql = “UPDATE search6 SET
email = ‘$email’,
description = ‘$comments’,
 etc 
region = ‘$region’
WHERE id = ‘$id’“);

-Original Message-
From: Chris Payne [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 3:18 PM
To: [EMAIL PROTECTED]
Subject: MySQL Update help needed


Hi there,

Can anyone see what is wrong with this query?  I am trying to update some
fields, if I do an echo everything looks good but it doesn't update the
fields in the DB - am I missing something obvious here?

Thanks for your help

Chris
www.planetoxygene.com

$mysql_query ("UPDATE search6 SET email = '$email',description =
'$comments',category = '$category',url = '$url',type = '$type',country =
'$country',rating = '$rating',fname = '$fname',state = '$state',region =
'$region',city = '$city' WHERE id = '$id'");



-- 
PHP Database 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-DB] tracking users...

2002-01-21 Thread Peter Lovatt

Hi

I use

$sessionID = md5(uniqid(rand()));

setcookie (sessionID , $sessionID ,0 , "" , "" ,0);

which works

hth

Peter

> -Original Message-
> From: jas [mailto:[EMAIL PROTECTED]]
> Sent: 22 January 2002 06:51
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] tracking users...
>
>
> I am fairly new to PHP and have setup a site that connects to a
> MySQL db to
> store different information from our users, however what I would like to
> setup is something that I could place on a few pages to track users for
> demographic purposes.  What I need to do is as a page is visited I need to
> generate a random alpha numeric identifier to be used as a
> session variable
> for a cookie and also have that cookie's information be placed
> into a MySQL
> database for later retrieval.  If anyone has a good resource tutorial on
> this type of function I would greatly appriciate it.  Oh and yes
> I have done
> quite a bit of research on php.net on both the session() and the
> setcookie()
> functions.  =)  Thanks again. Jas
>
>
>
>
> --
> PHP Database 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]


-- 
PHP Database 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]




[PHP-DB] Re: password problem

2002-01-21 Thread Joe Van Meer

Post up some code and somebody will help :) Joe



James Kupernik <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm creating this form where the person needs to enter a password to move
> on. When they enter the password it just loops back to enter the password
> and doesn't move on. But then I remove the requirement for a password the
> page moves on and loads the information from the DB. Why is this?
>
>



-- 
PHP Database 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]




[PHP-DB] Re: Counter view total

2002-01-21 Thread Joe Van Meer

Hi there, you could use the SUM function in your sql statement...like "SELECT 
SUM(count_view) FROM TABLENAME";

Hope this helps :) Joe 


  Barry Rumsey <[EMAIL PROTECTED]> wrote in message 
3C4C4D15.0A.00872@weiz-main">news:3C4C4D15.0A.00872@weiz-main...
In one of my tables I have a field called count_view, How do I add all the 
totals up  to  come up with one grand total of views. 
   
   
  
IncrediMail - Email has finally evolved - Click Here



[PHP-DB] Best web stats package with PHP4/MySQL

2002-01-21 Thread Brian Tegtmeier

What's up guys? I was wondering if any of you knew of a stats package written in PHP4 
and MySQL that has the same tracking features and reports as WebTrends and is free for 
download. 

Any suggestions would be kosher



-- 

___
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


1 cent a minute calls anywhere in the U.S.!

http://www.getpennytalk.com/cgi-bin/adforward.cgi?p_key=RG9853KJ&url=http://www.getpennytalk.com




-- 
PHP Database 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-DB] theme header query

2002-01-21 Thread DL Neil

By what do you mean code should be readable ?

=look at the code you've quoted below. Is it easy to read - can you even easily 
distinguish where one
instruction ends and another begins?

=does it work now?

=what does the .cx TLD have to do with Kiwi Xtra?
=dn


---Original Message---

From: DL Neil
Date: Tuesday, 22 January 2002 8:09:02 a.
To: Barry Rumsey;
Subject: Re: [PHP-DB] theme header query

Tables should be opened and closed
- and (please) code should be readable!
=dn

- Original Message -
From: Barry Rumsey
To: [EMAIL PROTECTED]
Sent: 21 January 2002 17:54
Subject: [PHP-DB] theme header query


I'm trying toadd thefollowing codeto atheme:
."\n"
."$sqlhostname = "localhost"; $login = ""; $password = ""; $base = "xplyrics"; 
$db_connect =
mysql_connect($sqlhostname,$login,$password); $base_selection = 
mysql_select_db($base,$db_connect);$query =
"SELECT COUNT(*) FROM xp_topics WHERE artist='artist' ORDER BY topicid DESC LIMIT 1"; 
$numartist =
mysql_query($query) or die("Select Failed!"); $numartist = 
mysql_fetch_array($numartist); Total Artists:
$numartist[0]; \n"
But when I try and load that page it comes back blank. Am I missing something or it 
just wont work.







  IncrediMail - Email has finally evolved - Click Here


-- 
PHP Database 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]




Fw: [PHP-DB] tracking users...

2002-01-21 Thread Andrés Felipe Hernández

jas:
> - Original Message -
> From: "jas" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, January 21, 2002 10:50 PM
> Subject: [PHP-DB] tracking users...


 > I am fairly new to PHP and have setup a site that connects to a MySQL db
to
 > store different information from our users, however what I would like to
 > setup is something that I could place on a few pages to track users for
 > demographic purposes.  What I need to do is as a page is visited I need
to
 > generate a random alpha numeric identifier to be used as a session
variable
 > for a cookie and also have that cookie's information be placed into a
MySQL
 > database for later retrieval.  If anyone has a good resource tutorial on
 > this type of function I would greatly appriciate it.  Oh and yes I have
done
 > quite a bit of research on php.net on both the session() and the
setcookie()
 > functions.  =)  Thanks again. Jas

 So I supose the problem is getting a random alpha numeric identifier , am i
 right?

 If so, what are the specifications of that identifier?

 Right now, the use of crypt/dcrypt function comes to my mind, but then you
 would need to use the
 mecrypt library.

 If you don't need something that sofisticated try generating a random
number
 and then
 use char() and ord() to retreive the info.

 hope this will help you,

 andrés

>


-- 
PHP Database 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]




[PHP-DB] iODBC module for PHP on linux

2002-01-21 Thread Thomas Spellman

Hi,

I'd like to use iODBC in mod_php (Apache DSO) on linux to access an
Access database running on a Windows box elsewhere.  I'm using an RPM of
mod_php.  Is it possible to compile the iODBC support as a PHP module
without having to recompile mod_php?  If so, how?  Does iODBC have to be
compiled with support for php?

Thanks for any help,

Thomas


-- 
PHP Database 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-DB] theme header query

2002-01-21 Thread DL Neil

Tables should be opened and closed
- and (please) code should be readable!
=dn

  - Original Message - 
  From: Barry Rumsey 
  To: [EMAIL PROTECTED] 
  Sent: 21 January 2002 17:54
  Subject: [PHP-DB] theme header query


I'm trying toadd thefollowing codeto atheme:

."\n"

."$sqlhostname = "localhost"; $login = ""; $password = ""; $base = 
"xplyrics"; $db_connect = mysql_connect($sqlhostname,$login,$password); 
$base_selection = mysql_select_db($base,$db_connect);$query = "SELECT COUNT(*) FROM 
xp_topics WHERE artist='artist' ORDER BY topicid DESC LIMIT 1"; $numartist = 
mysql_query($query) or die("Select Failed!"); $numartist = 
mysql_fetch_array($numartist); Total Artists: $numartist[0]; \n"

But when I try and load that page it comes back blank. Am I missing something 
or it just wont work.

   
   
   
  
IncrediMail - Email has finally evolved - Click Here 



[PHP-DB] tracking users...

2002-01-21 Thread jas

I am fairly new to PHP and have setup a site that connects to a MySQL db to
store different information from our users, however what I would like to
setup is something that I could place on a few pages to track users for
demographic purposes.  What I need to do is as a page is visited I need to
generate a random alpha numeric identifier to be used as a session variable
for a cookie and also have that cookie's information be placed into a MySQL
database for later retrieval.  If anyone has a good resource tutorial on
this type of function I would greatly appriciate it.  Oh and yes I have done
quite a bit of research on php.net on both the session() and the setcookie()
functions.  =)  Thanks again. Jas




-- 
PHP Database 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-DB] limit sytax error

2002-01-21 Thread Bogdan Stancescu

Quoting from the MySQL manual:
In MySQL Version 3.23, you can use LIMIT # to ensure that only a given
number of rows are changed.

So then, it's LIMIT # instead of LIMIT #,#

Obviously, the way around it would be using WHERE instead of LIMIT, but
I don't know your table structure so I can't provide any more details.

Bogdan

James Kupernik wrote:

> when I try to do the update with a limit on which records, it gives me a
> sytax error on the limit, is there anyway to get around this?
>
> UPDATE catalogs SET PROCESSED = 'Y' LIMIT $i,10
>
> thanks
>
> --
> PHP Database 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]

-- 
PHP Database 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-DB] limit sytax error

2002-01-21 Thread Robert V. Zwink

Looks like LIMIT can only contain one number, when using UPATE the offset
parameter cannot be added.

http://www.mysql.com/doc/U/P/UPDATE.html

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1, [col_name2=expr2, ...]
[WHERE where_definition]
[LIMIT #]

So . . .
"UPDATE catalogs SET PROCESSED = 'Y' LIMIT $i,10"
would have to be
"UPDATE catalogs SET PROCESSED = 'Y' LIMIT $i"



-Original Message-
From: James Kupernik [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 11:56 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] limit sytax error


when I try to do the update with a limit on which records, it gives me a
sytax error on the limit, is there anyway to get around this?

UPDATE catalogs SET PROCESSED = 'Y' LIMIT $i,10

thanks



--
PHP Database 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]


-- 
PHP Database 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]




[PHP-DB] theme header query

2002-01-21 Thread Barry Rumsey








  
  I'm trying toadd thefollowing codeto atheme:
  ."\n"
  ."$sqlhostname = "localhost"; $login = 
  ""; $password = ""; $base = "xplyrics"; $db_connect = 
  mysql_connect($sqlhostname,$login,$password); $base_selection = 
  mysql_select_db($base,$db_connect);$query = "SELECT COUNT(*) FROM 
  xp_topics WHERE artist='artist' ORDER BY topicid DESC LIMIT 1"; $numartist 
  = mysql_query($query) or die("Select Failed!"); $numartist = 
  mysql_fetch_array($numartist); Total Artists: 
  $numartist[0]; \n"
  But when I try and load that page it comes back blank. Am 
  I missing something or it just wont work.
  





	
	
	
	
	
	
	




  IncrediMail - Email has finally evolved - 
Click 
Here



[PHP-DB] Counter view total

2002-01-21 Thread Barry Rumsey








  In one of my tables I have a field called count_view, How do I add 
  all the totals up  to  come up with one grand total of 
  views.







  IncrediMail - Email has finally evolved - 
Click 
Here

[PHP-DB] limit sytax error

2002-01-21 Thread James Kupernik

when I try to do the update with a limit on which records, it gives me a
sytax error on the limit, is there anyway to get around this?

UPDATE catalogs SET PROCESSED = 'Y' LIMIT $i,10

thanks



-- 
PHP Database 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-DB] select and update together

2002-01-21 Thread Robert V. Zwink

http://www.mysql.com/doc/U/P/UPDATE.html

UPDATE catalogs SET PROCESSED = "Y" WHERE PROCESSED IS NULL LIMIT $i,10

Is this what you are looking for?

Robert V. Zwink
http://www.zwink.net/daid.php

-Original Message-
From: James Kupernik [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 10:56 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] select and update together


Is it possible to select 10 records that have a NULL field and update that
field to become Y instead of NULL? If so what would this syntax be?

This is what I have now

$result = mysql_query("SELECT * FROM catalogs WHERE PROCESSED IS NULL LIMIT
$i,10");

I want to add an UPdate to it, but not sure it's possible.

Thanks for any advice you can provide.

James



-- 
PHP Database 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]


-- 
PHP Database 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]




[PHP-DB] select and update together

2002-01-21 Thread James Kupernik

Is it possible to select 10 records that have a NULL field and update that
field to become Y instead of NULL? If so what would this syntax be?

This is what I have now

$result = mysql_query("SELECT * FROM catalogs WHERE PROCESSED IS NULL LIMIT
$i,10");

I want to add an UPdate to it, but not sure it's possible.

Thanks for any advice you can provide.

James



-- 
PHP Database 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-DB] Mysql-class

2002-01-21 Thread Jason Wong

On Tuesday 22 January 2002 22:35, Johannes Hiemer wrote:

First of all, please keep the discussion on the list!

> >What did you want it to do?
>
> I want it to do things like inserting into Mysql-dbs
> Fetching arrays. Just every Mysql-command which
> Is also suported in PHP.
> What is it doing now?
> It is doing nothing if I create a class of it.
> If I create a  class using the fetch_array function
> And echoing it after it just says: Object.
> What error does it give, if any?
> S. a.

Looking back at your code:

>  $test = new get_db();
>  $test -> connect();
>  $test -> db_query("SELECT * FROM topics");
>  $test -> fetch_array("SELECT * FROM topics");
>  echo "$test";


You should be using:

  $test->connect();

etc (note there are no spaces surrounding the "->").

BTW, I'm not trying to put you off, but why are you writing your own class of 
mysql db functions? There are already loads out there which are tested (and 
working!). If this is an exercise in learning how to write classes then good 
luck :)


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
The perfect lover is one who turns into a pizza at 4:00 A.M.
-- Charles Pierce
*/

-- 
PHP Database 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-DB] Combining INSERT...SELECT and INSERT INTO

2002-01-21 Thread Markus Lervik

On Tuesday 15 January 2002 16:04, you wrote:

> On 1/14/2002 12:54 PM +0200 Markus Lervik wrote:
> > Is there any way to combine INSERT...SELECT and INSERT INTO so
> > one could insert a new row with a few values inserted by hand and
> > others from another table? something like
> >
> > INSERT INTO mag_table (mag_id,issn,year,info,volume,numbers,remarks)
> > VALUES  ( (SELECT id FROM mag_names WHERE mag_names.name="Asdf"),
> > "1234-5678","2001","foobar","1-4","1-52","foobar");
>
> Try doing something like:
>
> INSERT INTO mag_table (mag_id,issn,year,info,volume,numbers,remarks)
>   SELECT mag_names.id as mag_id,
>   '1234-5678' as issn,
>   '2001' as year,
>   'foobar' as info,
>   '1-4' as volume,
>   '1-52' as numbers,
>   'foobar' as remarks,
>   FROM mag_names WHERE mag_names.name='Asdf';
>
> I don't know if that will work as-is, but something along those lines
> should give you what you need.


Well, here's how I ended up doing it before I red your mail:


$concat_string = "SELECT CONCAT_WS(\",\",\"";

if(isset($inputName)) { 

if(!$result=mysql_query("SELECT id FROM mag_names WHERE 
mag_names.name=$inputName")) {
die("error");
}

if(!$row=mysql_fetch_assoc($result)) {

if(!$result=mysql_query("INSERT INTO mag_nimes (name) VALUES 
\"$inputName\"")) {

die("error");

}

elseif(!$result=mysql_query("SELECT id FROM mag_names WHERE 
mag_names.name=$inputName")) {

die("error");
}
}

$row=mysql_fetch_assoc($result);

$concat_string .= " Name=\\\"" . $row["id"] . "\\\"\",\"";

}

Then concatenate Name, ISSN and everything else to construct the end of my 
nice little UPDATE mag_table SET ... -sentence, pass it through mysql and 
concatenate the UPDATE sentece and the result from the previous mysql query,
stick a little duct tape here, a bit of super glue there and a few five-inch 
nails and stuff the whole thing down mysql. : )

Well, it works. : )

Cheers,
Markus

-- 
Markus Lervik
Linux-administrator with a kungfoo grip
Vaasa City Library - Regional Library
[EMAIL PROTECTED]
+358-6-325 3589 / +358-40-832 6709

-- 
PHP Database 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-DB] MySQL Update help needed

2002-01-21 Thread DL Neil

Hi Chris,

Can anyone see what is wrong with this query?  I am trying to update some fields, if I 
do an echo everything
looks good but it doesn't update the fields in the DB - am I missing something obvious 
here?

$mysql_query ("UPDATE search6 SET email = '$email',description = '$comments',category 
= '$category',url =
'$url',type = '$type',country = '$country',rating = '$rating',fname = '$fname',state = 
'$state',region =
'$region',city = '$city' WHERE id = '$id'");


=the story of my life I clean myself up and "everything looks good", but still none of 
the popular crowd are
interested...

=it is good that you have taken the precaution of an 'echo', and I'll assume that the 
db/tbl are connected and
opened properly.

=how do you know that "it doesn't update the fields"? If you are using a PHP MySQL_ 
fn, then remember that
you'll only get a response if the row was actually updated (ie (possibly, but only) 
the first time you throw
that particular dataset at the db. What is the result from the function - a 
resultset/resource identifier or
something else?

=have you taken the debug-output from the echo and copy-pasted it into either the 
MySQL client or an admin pkg?
These will give you different error responses and show the DBMS' response to the 
combination of SQL and data.

=my concern would be with the commas that don't appear to be followed by spaces. I 
always add the db_connector
argument, and (just in case you haven't 'edited' the line for the email) assign the 
resultset to something.

=if the above does not help, please provide more information, and we'll get down and 
boogie - even without the
'popular people'...
=dn



-- 
PHP Database 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]