Home Page   #c  #ruby-lang  #cisco  #mysql  #apache  #javascript  #java  #perl  #php  #openmoko   Wallpapers Girl
Reliable $1 Web Hosting by 3iX

Channels


#mysql

28 October 2007


Total 17 pages. You are browsing page 3/17.

First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last

01:08 <****> Ok I'll look for it
01:08 <****> tators: have you looked at the string functions?
01:08 <****> hrm I guess not
01:08 <****> !man string functions
01:08 <****> (String Functions) : http://dev.mysql.com/doc/mysql/en/string-functions.html
01:09 <****> tators: there are a few ways. If you wanted to remove all " it you can use replace, else just a substring to remove first and last character, etc.
01:09 <****> tators: use the replace() text function.
01:10 <****> ALTER TABLE tbl AUTO_INCREMENT = 100; , won't that affect the entries that are already in the table?
01:10 <****> nopez
01:10 <****> hrm
01:10 <****> No it will not, although it may rebuild the entire table anywa
01:10 <****> there are 3 million rows
01:10 <****> this could take a long time
01:10 <****> can I do replace with 3 million rows
01:11 <****> or should I just kill the first and last
01:11 <****> tators: either will work. Don't use replace unless you are sure none of the " are legit
01:12 <****> Next Autoindex 9
01:12 <****> yaay it worked, thanks =)
01:13 * chadmaynard wonders if it is MyISAM or Inno
01:14 <****> when performing an insert query and the key already exists does it throw an error?
01:14 <****> or return something?
01:14 <****> if it is unique
01:14 <****> It will throw an error
01:15 <****> ^if it is unique
01:15 <****> yeah it is
01:15 <****> okay, one moment
01:17 <****> Okay so like $result = mysql_query(...); what will $result contain given an error?
01:17 <****> Dunno, consult the PHP documentation
01:17 <****> no
01:17 <****> $result will be false
01:17 <****> okay, am I doing it wrong?
01:18 <****> mysql_query OR die(mysql_error());
01:18 <****> that will kill the script and display the SQL error. I wouldn't use that in production
01:18 <****> yeah well I want to do something if the insert fails.
01:18 <****> you can always check mysql_error() after mysql_query if you want
01:18 <****> In PHP, die is wholly unuseful; never use it.
01:19 <****> so if(!$result) would suffice
01:19 <****> prefer to throw an exception, then at least you get a stack trace
01:19 <****> But ideally configure your mysql client stuff to throw an exception automatically on error
01:19 <****> You really need to reduce the amount of error handling code to the least possible
01:19 <****> and have it to do the right thing by default
01:20 <****> I wouldn't say die() isn't useful
01:20 <****> (which is usually stop the script, log context etc)
01:20 <****> no it's not for an error. I just don't want to do and if the key is in the db then add it or do something else. I'm just gonna do "add it and if you get an error do something else"
01:20 <****> No, die is not useful. In Perl it is useful, in PHP it is some kind of dodgy alias for print(something);exit
01:21 <****> print(something); exit; isn't useful?
01:21 <****> MarkR42, die() in PHP is an alias for exit().
01:21 <****> No, because if you do that inside a function then you've no idea where it's called from
01:21 <****> and seeing are you're *probably* doing everything inside a function
01:21 <****> Agree, exceptions are teh win.
01:21 <****> and if you've any sense, all your DB access will go through the same, or a small group of functions
01:21 <****> it's good for debugging your queries though.
01:21 <****> die() really isn't useful as you can't see the stack trace
01:23 <****> you can call the trace from die if you want.
01:23 <****> No you can't
01:23 <****> I said not to keep it in production code but that's not something that makes it unuseful
01:31 <****> MarkR42: what do you mean No you can't?
01:33 <****> die() does not give you a stack trace
01:34 <****> Suppose a function throws an error, which is called dozens of times on the page... how do you know which instance it was?
01:34 <****> http://rafb.net/p/bgiUAH33.html
01:34 <****> i use it like that often during devel
01:35 <****> Of course I take those out and put in a logging facility later but that's a pain during development to have to check logs
01:35 <****> Oh I see, is it as useful as the one throwing an exception prints?
01:35 <****> I just throw an exception- in production my default exception handler behaves differently
01:36 <****> Moreover, I use PDO which throws an exception anyway if a database error happens
01:36 <****> i don't understand the question
01:36 <****> no one likes PDO except you and will though.
01:36 <****> and will likes it cause he works with the guy that wrote it
01:36 <****> But it is Right
01:36 <****> my point is that die() isn't useless
01:36 <****> Actually some things are wrong- it is too flexible- throwing an exception on error can be disabled
01:37 <****> I use it all the time
01:41 <****> Exceptions are probably easier for decent-sized apps, though, because their default behavior can be customized.
01:42 <****> And of course they can be caught.
01:45 <****> Is there any way to get a dump of the command history that a user has gone through? I want to recall the username/passwd/priveleges of a user that I added to a certain db to make my php script work
01:46 <****> Simetrical: Of course
01:47 <****> Simetrical: that doesn't make die() useless
01:47 <****> Just less useful than the alternative, I would say.
01:48 <****> Simetrical: if you are writing a small factorial function like I did you would be wasting your time with the alternative
01:48 <****> xtor_: depends.
01:48 <****> xtor_: check your home directory for mysql history files
01:48 <****> It doesn't take very much longer to type "throw new Exception" than to type "die".
01:49 <****> processing the exception properly does
01:49 <****> i would imagine. I don't use php, of course.
01:51 <****> is it really not possible to default a DATETIME field to Now() for when a record is created? I already have a TIMESTAMP field for "last update time", but I want a defaulted "Created date" field.
01:51 <****> rgr: only with triggers
01:52 <****> chadmaynard: thanks. Dang it. And phpadmin export doesnt take care of "if exists" for triggers so the import of an exported database doesn't work.
01:52 <****> chadmaynard, the point is, you don't process the exception, you let it propagate up the call stack and kill the process, just like die(). And it also prints out the message you give it by default, like die() (at least in Python and probably PHP), along with possibly a call stack (by default in Python, by customization in PHP).
01:53 <****> Simetrical: mark said die won't do that
01:54 <****> die doesn't print call stacks by default in PHP, at least.
01:54 <****> rgr: foo on that
01:54 <****> Nor do exceptions, granted.
01:54 <****> Simetrical: we were talking about PHP
01:54 <****> They do the same thing, I guess, in PHP.
01:54 <****> Although I think exceptions only exist in PHP 5?
01:54 <****> right
02:12 <****> how can i make set a datetime field to default to now()
02:12 <****> Where will I find a file such as .mysql_history at? Its not in /root or /home/xtor
02:14 <****> section31: only TIMESTAMP columns can do that. You could use a trigger, though, if you have version 5.0 or higher
02:14 <****> Shrews, oh i see


Total 17 pages. You are browsing page 3/17.

First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last


Tutti i nuovi CAP Italiani. Come ottenere il database completo