[PHP-DB] Re: Recursive photo gallery removal problem
Tom, I understand you have a structure of folders, each with a single parent folder. You want to be able to delete one specific folder and then have all folders directly or indirectly under that folder removed at the same time. This is easy to do using a foreign key with an on delete clause. Declare a table like this: CREATE TABLE gallery ( gallery_idint, parent_gallery_id int, PRIMARY KEY ( gallery_id ), FOREIGN KEY ( parent_gallery_id ) REFERENCES gallery ( gallery_id ) ON UPDATE CASCADE ON DELETE CASCADE ); The foreign key clause establishes a relationship between two records in the gallery table, a reference from on gallery to its parent. The on delete cascade part says that when the gallery record referenced from this record (i.e. the parent) is deleted, this gallery record is to be deleted too. This will be done recursively by the database system backend. To delete a subtree of galleries, you simply delete the record for the topmost folder, the database backend will take care of the rest. I'm not sure how well foreign key and on delete is supported by MySQL, but this is something PostgreSQL has been doing well for a long time. --- Geir Pedersen http://www.activio.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: exporting data to excel
Matthew, I am looking for the easiest way to export data to an excel file. Is the eaiest way to use PHP's file handling functions? I assume you want to delivery the execl file to a web user. Then there is no need to write the data to disk, you can generate the whole thing on the fly while you deliver it to the user. Here is a basic description on how: 1) Create a PHP document to generate the execl file and make sure the script produces HTTP headers telling the user agent that it is receiving an excel document. Start the script with: header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); The content disposition header says that the execl file is to be stored on disk. 2) Generate the spreadsheet data as a list of newline separated rows with tab separated fields: echo field1\tfield2\t...\n; 3) Set up a link to the new PHP document. When a user clicks on that link, he will be prompted by his user agent on where to save the excel file. --- Geir Pedersen http://www.activio.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ORA-01460 error when useing bind sql on oracle from php
I get ORA-01460: unimplemented or unreasonable conversion requested when useing bind-sql on Oracle 9i. I am useing OCI 8.1 client in PHP. What is wrong? And what does this message mean? Here is the code: ---***--- $bindarray1=array(':project1'=$project); $bindarray1[':userid']=$userid; $rs = sql_query($qs,$bindarray1); function sql_query($qs,$bindargs) { $stmt = @OCIParse($this-db_sqlhandler, $qs); if (!$stmt) { return false; } //bind all the variables if (is_array($bindargs)){ foreach ($bindargs as $bindname = $bindvalue){ OCIBindByName($stmt,$bindname,$bindvalue,-1); } } if (@OCIExecute($stmt)) { return $stmt; } $DB_ERROR = OCIError($stmt); return $DB_ERROR; } ---***--- vardump of bindargs: array(2) { [:project1]= int(1) [:userid]= string(5) 10001 } vardump of DB_ERROR: array(4) { [code]= int(1460) [message]= string(62) ORA-01460: unimplemented or unreasonable conversion requested [offset]= int(0) [sqltext]= string(365) SELECT acl.prjid, acl.groupid, acl.read_access , acl.write_access,acl.delete_access,acl.change_access FROM StructureTreeTbl outree, GroupChildrenTbl gg2, MembersTbl memb2, ACL acl WHERE (memb2.personid=:userid AND memb2.groupid=gg2.gchildid AND gg2.groupid=outree.orgchild AND outree.orgid = acl.groupid AND acl.prjid=:project1) } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ORA-01460 error when useing bind sql on oracle from php
Sorry about replying to my own posts, but... Problem solved! As OCIBindByName is binding to the actual variable, that variable must not be changed. I modified my script to look like this: ---***--- $ci=0; foreach ($bindargs as $bindname = $bindvalue){ ${bindval$ci}=$bindvalue; OCIBindByName($stmt,$bindname,${bindval$ci},-1); $ci++; } ---***--- Are Pedersen wrote: I get ORA-01460: unimplemented or unreasonable conversion requested when useing bind-sql on Oracle 9i. I am useing OCI 8.1 client in PHP. What is wrong? And what does this message mean? Here is the code: ---***--- $bindarray1=array(':project1'=$project); $bindarray1[':userid']=$userid; $rs = sql_query($qs,$bindarray1); function sql_query($qs,$bindargs) { $stmt = @OCIParse($this-db_sqlhandler, $qs); if (!$stmt) { return false; } //bind all the variables if (is_array($bindargs)){ foreach ($bindargs as $bindname = $bindvalue){ OCIBindByName($stmt,$bindname,$bindvalue,-1); } } if (@OCIExecute($stmt)) { return $stmt; } $DB_ERROR = OCIError($stmt); return $DB_ERROR; } ---***--- vardump of bindargs: array(2) { [:project1]= int(1) [:userid]= string(5) 10001 } vardump of DB_ERROR: array(4) { [code]= int(1460) [message]= string(62) ORA-01460: unimplemented or unreasonable conversion requested [offset]= int(0) [sqltext]= string(365) SELECT acl.prjid, acl.groupid, acl.read_access , acl.write_access,acl.delete_access,acl.change_access FROM StructureTreeTbl outree, GroupChildrenTbl gg2, MembersTbl memb2, ACL acl WHERE (memb2.personid=:userid AND memb2.groupid=gg2.gchildid AND gg2.groupid=outree.orgchild AND outree.orgid = acl.groupid AND acl.prjid=:project1) } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP-DB] Conversion from access to mysql
Hi, Check out MyAccess at http://www.accessmysql.com/. It works for me. The manual points out some things to keep in mind when converting. /Dann -Oprindelig meddelelse- Fra: Chris Grigor [mailto:[EMAIL PROTECTED]] Sendt: 10. september 2002 11:48 Til: [EMAIL PROTECTED] Emne: [PHP-DB] Conversion from access to mysql Hey there all This is more than likely a common question, anyone have any guidelines, do's or dont's about converting an access db to mysql db... Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] undefined index
Hi! Drop the quotes around your array keys. It should be $row[imageurl] for example. -- Henning Kilset Pedersen Anarchy Online Server Operations Oracle, PHP, e-Commerce etc. Funcom Oslo AS -Original Message- From: Petra [mailto:[EMAIL PROTECTED]] Sent: 1. mai 2001 03:29 To: [EMAIL PROTECTED] Subject: [PHP-DB] undefined index hi to all I try to get data listed out of my database with the statement ... while ($row = mysql_fetch_array($sql)) { $image = $row[imageurl]; $id = $row[productID]; $name = $row[cdescription]; ... If i havent got anything in that field in my database I get the error message in my browser Undefined index: imageurl in ... How can I overcome that problem? Is there a way to define a index if that occurs and make it to not produce that error message? Hope I have explained it understandable enough. If you need to know more details let me know, I would appreciate any help I could get. Thanx P. -- 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]