Jump to content

E_Leeder

Members
  • Posts

    13
  • Joined

  • Last visited

E_Leeder's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've never heard of clustered indexes, thanks for sharing. Just considering mysql workbench here (although it may be applicable outside of it; I haven't tested yet)... I know the row order isn't explicit in mysql or relation databases in general, but it's strange that if I mark a varchar column as unique, the default sorting is by the varchar column, not the primary key. Strange because it IS sorting by the varchar column at all, when it should be defaulting to the insert order or the primary key. Maybe it is just a workbench issue? I did more testing today and discovered that if I add another varchar column, and mark it as unique, (and just leave it full of nulls) the default sorting reverts to sorting by the auto-incrementing primary key column (which maps to insert order). So something is defaulting to prefer ordering by the first varchar(20) column when there is only a varchar(20) and my AI,NN, UN, PK column, but that default sorting changes if another varchar column is added.
  2. I have a table with two columns. The first is an id column, set to be my primary key, non null, unique, int, and auto increment. The second is a varchar(10) column. Very strangely, when I set the varchar(10) column to unique, and try to edit the table in workbench, the table is automatically ordered by my varchar column, and not my id (primary key column). If I mark the varchar(10) column as not unique, data is ordered by the primary key, as expected. What is going on here? I expected the primary key to be default ordering for the table. I hope to not use an ORDER BY clause.
  3. I read through the link but I think I missed it where it says you can't echo class constants within static clases. Could you please point me to where it indicates that? I found something like it mentioned for curly syntax variables, but I don't think it applied to my case, and I am looking for better understanding.
  4. Can you echo class constants? This does not work for me. echo “here is a class constant: self::CLASS_CONSTANT”; // using double quotes Instead I *must* concatenate it: echo ‘here is a class constant: ‘ . self::CLASS_CONSTANT; But of course I do not have to do this with a normal variable, which will echo a variable fine: echo “my name is $name_variable”; Am I doing something wrong or is this normal behavior?
  5. Thanks for sharing, Barand. The string output I want doesn't need to be THAT legible for humans because it is just going in a log, and the log will be parsed. But if I do need to look at an individual log entry, I should be able to make sense of it (even if it takes a lot of effort).
  6. Yes, very close to something like that, thanks. Except that I'd like to prepend a string to each array print out, and have the ability to put multiple string/array combinations in the function. I have a better idea of what would be necessary now, thanks to you example. (The data doesn't make sense, just using it as an example.) $string1 = 'There are the books: '; $array1 = ('book1', 'book2', 'book3'); $string2 = 'There are the pages: '; $array2 = ('page1', 'page2', 'page3'); function printArray($string, $array, $string2, $array2) { // do the work return $string; } But how would I make a function take an indefinite number of arguments? I googled it and came up and func_get_args(). So would there be any problems with this? function printArray($args) { $args = func_get_args() $string = ''; foreach ($args as $arg) { if (is_array($arg) { $string .= print_r($arg, true); } else { $string .= $arg; } } return $string; } any problems with this code or ways to make it better?
  7. Thanks, I should have thought of that. But I guess there is no way to have a variable that contains an array in a string because of the string to array conversion error? So a function like this is impossible? $variable = “These are the books: $userArray and these are the pages: $pagesArray”; // (double or single quoted) function usePrint_rOnAllArraysInString($variable) { // do the magic print_r on all arrays in the variable passed return $variable // all arrays in the string flattened into something like print_r does }
  8. If I wanted to print a string that contains a variable that also contains an array, how would I do so? I want to put the resulting echo into a log file. Example: “These are the books: $userArray and these are the pages: $pagesArray”; With just an array, I can use print_r($array, true) to get an array formatted for use in a string (which works well for my purposes) but this doesn’t work with two arrays unless I do this manually. (Such as setting the $user_array = print_r($userArray). But I want to write a function that will take a string, potentially containing arrays (as variables), and interpolate/make them legible for humans. (Some of the arrays are also multidimensional.) But it looks like I can't even concatenate a string and an array. $string = $string . $array. gives an error, array to string conversion. I don’t understand PHP very well so please explain what is going on here. and the best way to record something like the Example above.
  9. Simple question I know, but suprisngly hard to google for because {} is used for so much more in php, like if, foreach, etc. In the code I read it in it looked like it was evaluating the variable and then turning it into plain text to then be interpreted as-is in the script... but I was confident in this assessment.
  10. You were right, output buffering was turned on. I turned it off, and received the error. Thanks for that.
  11. I am in a dev environment with all errors on (I think... the setting is: error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT)). Does the code I posted cause an error for you? (Other things cause me headers already sent errors.)
  12. I'm trying to diagnose headers already sent errors. I know that I can see the line and comment it out (or do something) based on the error given, but what I don't understand is why they seem to occur sometimes but not others. The code below sends things to the browser before calling session_regenerate_id(true), which will cause headers already sent errors if headers have already been sent. <?php echo 'hello world'; $test_variable = 'some variable to var_dump'; var_dump($test_variable); session_regenerate_id(); ?> I thought that this should fail and give me a headers already sent error, but it doesn't. I frequently echo to a page before calling a header action, and sometimes it works, sometimes it doesn't, like in the case above. What's going on to give me an error elsewhere but not here?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.