Jump to content

RussellReal

Members
  • Posts

    1,773
  • Joined

  • Last visited

Everything posted by RussellReal

  1. thats what I meant by 'superficial'. IDK If your post was in reference to him or me
  2. more than likely yes, I suppose thats true too.. However you work it, I mean, I'm just saying you're probably better off constanting all constant data, even error messages should be constants that or in 1 long csv file or something, because the ultimate goal of an MVC is portability, and having a centralized message/language file, and easy to modify, familiar, simplistic code configuration will make your MVC stand out more.
  3. the ^ denotes start, and $ denotes end if you're in multiline mode, ^ is the start of the string, and $ is the end of a string, however if you're not in multiline (dot all), then ^ is the start of a line, and $ is the end of a line.. so if you supply a string like: 'abc123' a pattern like: '/.$/' will match '3' Hope I helped! Russell
  4. Honestly, you're going to be creating tons of constants anyway.. etc: OPTIONS_TABLE USERS_TABLE because when you move your app from 1 site to another, it may or may not be shared and shared hosting usually prepends your table names, or database names.. and tbh, runtime ini changes are superficial changes, so most php installations should allow this behavior, but, it makes no sense not to keep the static information in a constant, hence the name "constant"... and constants are always in the global scope, so, no need to pass other objects into newer objects.. Furthermore, you shouldn't need to do the above either way, more than once, if you're extending other, more top level classes.. for example. class User extends DBClass { } or you could create an object factory.. either way, the only thing you're doing by not using constants, is probably creating a very frustrating application (Magento?) I hope I helped, Russell
  5. or.. if you're going to use preg match anyway <?php if (preg_match('/^\d{7}$/',$number)) { // valid number } ?>
  6. Add me to skype: RussellReal I could help you here, but that would be alot of typing, and I'm too fresh-awake for that, still haven't washed my face even LOL - Russell
  7. CKPD, stripslashes isn't a security measure, it is a function used to remove slashes when magic quotes is set on, if you don't remove the added slashes, then you run mysql_real_escape_string, you will have double slashes on your single quotes, making them still insecure.. so in many cases you NEED strip slashes.. however, you don't need to clean expected floats and expected integers, type casting does that more efficiently than anything else.. for example.. $id = (int) $_GET['article_id'];
  8. lol guys, I won't lie, I woke up like 30 mins ago, and like, I came to this post and I feel like the sleep made me retarded coz in my head I'm like "wuhhh", aha! Anyway, good job xyph! Russell
  9. Uhm, add my skype: RussellReal my MSN isn't installed on my new laptop, which I'm currently on, I'm installing it as I write this, but incase its urgent my skype is always available. I have many more clients on skype, so I kinda prioritize Thanks, Russell
  10. <?php $x = array(); $x[] = array('A7',25,25.0000); $x[] = array('A7',50,25.3000); $x[] = array('A7',100,26.2000); $x[] = array('A7',250,29.2000); $x[] = array('A7',500,37.2000); $x[] = array('A7',1000,57.2000); $x[] = array('A7',2500,63.2000); $x[] = array('A7',5000,70.7500); $x[] = array('A7',10000,95.2800); $x[] = array('A7',15000,138.8000); $x[] = array('A7',20000,175.8500); $x[] = array('A7',25000,223.5000); $x[] = array('A8',25,25.0000); $x[] = array('A8',50,25.3000); $x[] = array('A8',100,26.2000); $x[] = array('A8',250,29.2000); $x[] = array('A8',500,37.2000); $x[] = array('A8',1000,57.2000); $x[] = array('A8',2500,63.2000); $x[] = array('A8',5000,70.7500); $x[] = array('A8',10000,95.2800); $x[] = array('A8',15000,138.8000); $x[] = array('A8',20000,175.8500); $x[] = array('A8',25000,223.5000); $rows = array(); // associative array, key index will be A7 A8 etc etc.. $rows[0] = array(); // initial rows would be column names, so the key will just be 0 foreach ($x as $column) { // loop thru the jumbled up mess of information ONE TIME, to calculate the number of columns necessary if (!in_array($column[1],$rows[0])) { $rows[0][] = $column[1]; // append the column name } } // sort the column titles now sort($rows[0],SORT_NUMERIC); // then get count of this new column title array $count = count($rows[0]); // now just loop thru the $x array, and fill in the place values foreach ($x as $row) { $rowTtl = $row[0]; $rowQty = $row[1]; $rowVal = $row[2]; if (!isset($rows[$rowTtl])) $rows[$rowTtl] = array_pad(array(),$count,0); $rows[$rowTtl][array_search($rowQty,$rows[0])] = $rowVal; } // display table ?><table> <?php foreach ($rows as $rowName => $columns) { echo "<tr><td>{$rowName}</td>"; foreach ($columns as $cell) { echo "<td>{$cell}</td>"; } echo "</tr>"; } ?> </table> test link: http://myspacechickz.com/tester.php
  11. you could reverse gender and department, since you don't seem to be omitting gender anywhere there.. However, if you want a variable length argument list you could look into: func_num_args, func_get_args, and func_get_args func_num_args will tell you how many arguments were specified.. func_get_args will get an argument by index func_get_args will get all of the arguments
  12. Okay, I don't believe that this functionality gives you a reference to that specific variable in its localscope.. I believe it is returning A REFERENCE to the variable, and bringing it out into the global scope. And then all of the other local scope variables, are destroyed once the function ends.. the example PHP gives you, on that page, is a good example, because if the function wasn't returning a reference to a variable, you would only have the number contained within the other variable, not the variable reference contained in the other variable.. the reason the PHP example is good is because.. EXAMPLE A function abc() { $a = 5; return $a; } in the above context, when it returns $a, it will be evaluated prior to the return and it will only return the value 5.. but with this function: EXAMPLE B function &abc() { $a = 5; return $a; } it will return $a, not 5, but $a equates to 5.. but it gives you slightly more control over the variable $a, and slightly more options.. in example A, if you were to do this: function xyz(&$abc) { return ++$abc; } $x = ayx(abc()); it would most likely cause an error, as you're not supposed to pass non-variables as references.. but in example B the above code would prolly work just fine now, this seems a little retarded to do all of this to get the same outcome as you could get with probably the same or less amount of text, but in an OBJECT, it seems more likely to need this functionality.. but, I've never used this, and I'm a professional developer, so honestly, its not too important
  13. do you have an events table? do you have a datetimes table.. mysql is a relational database.. You're gonna wanna have tables like this: Events: idevent_text 1Baseball Game 2Science Convention Datetimes: iddate (YYYY-MM-DD)hour (HH)events_id (foreign key) 12012-01-20131 22012-01-20141 32012-01-20152 SELECT * FROM datetimes JOIN events WHERE events.id = events_id ORDER BY datetimes.date, datetimes.hour sorry, I said group by instead of order by, but, group by could work also
  14. strtotime and date however, Grissom, might have the best alternative, should strtotime fail to be what you need, since you can explicitly set how the function should handle that date.. thumbs up to grissom
  15. I've only ever done light work with CakePHP So I'm probably not the best for this question, but I did a quick google search, and came up with a result which sounds very close to what you're looking for: http://stackoverflow.com/questions/93632/cakephp-view-including-other-views however, you shouldn't need a separate view for a "view all posts" view, unless you plan to use that same view elsewhere, than I guess it makes sense to have it set up like an include, but, check the link above Sorry I wasn't enough help!
  16. Hello, I'd love to help you, can you show us a screenshot or dump of your database when filtering by a specific message string.. like do this query SELECT * FROM caresa6_$acct.allmsgs WHERE reported = 'n' AND string = 'abcUNIQUE123' also I think your issue doesn't lie in MySQL, its more-so in the rest of your code, so it could be good if you showed us that aswell.. Thanks!
  17. I don't understand, why do you need to to use multiple controllers to have access to multiple tables, just select or update or insert into the tables, unless each of your controllers has a different useraccount or database.. and even still, its just a matter of centralizing all of that information in an include file, and include that file into each of the controller files.. Sorry if I'm a little clueless here, care to elaborate more?
  18. GROUP BY date, time You could do that with mysql, but I have no idea about your db structure, so my best advice would be to skip that with php..
  19. try this instead <?php $availableHooks = array( 'init' => array(), 'exit' => array() ); function add_hook($mainHook,$appendFunction) { global $availableHooks; $availableHooks['init'][] = $appendFunction } function init($functions) { foreach ($functions as $func) { $func(); } } function exit($functions) { foreach ($functions as $func) { $func(); } } function run_hooks($hook) { global $availableHooks; if (isset($availableHooks[$hook])) $hook($availableHooks[$hook]); } ?> when adding a hook: <?php function runThis() { mysql_query("alalalalala"); } add_hook('init','runThis'); ?> then when its time for a hook: <?php run_hooks('init'); ?> that would be a million times better, and yes I know it uses global, sure you could probably avoid that, but I'm writing this fast eval() is bad
  20. you want your web server to push you a web page, you then want your web server to give you a link to screenshot a page.. this I know for certain.. but do you want your webserver to take the web server's screenshot, or the picture of the screen of the end user(client) what QuickOldCar is talking about, is for server side screenshots, not client side screenshots
  21. Well, firstly, lets explain your chosen method SELECT * FROM elsa_sc_roles a LEFT JOIN elsa_sc_context b ON (b.context_role_id = a.role_id AND b.context_sc_id = '".$edit_sc_id."') SELECT I'm sure you know what it means FROM elsa_sc_roles I guess you can count as "required tables", although its not all that simple, but lets move on LEFT JOIN elsa_sc_context ok, now lets explain this, left join basically means that "elsa_sc_context" is now to the right of "elsa_sc_roles", and that, it will not fail to successfully pull the collected data, so long as the >>LEFT TABLE<< has all the required data if the LEFT JOIN doesn't return any data, all the fields from that table are filled with NULL, now, we can use that, because in mysql NULL is false, so: IF(elsa_sc_context.context_id,1,0) basically means if "elsa_sc_context.context_id" is true (has a value), return 1 (bool:true) if it is FALSE(null or 0)then return 0 (bool:false) but, everytime you hit an elsa_sc_roles ROW, you will be scanning elsa_sc_context for a row that matches the ON conditions.. E.G. role_id = role_id, if at the END OF THE TABLE, there is no matches, all of the values will be filled in with false(0) ---------------------------------------------------------------------------------------------------------------------------- Here is how the two queries would have looked in your script: <?php $a = mysql_query("SELECT role_id, role_name_en, role_name_dk FROM elsa_sc_roles ORDER BY asc"); $edit_sc_id = (int) $edit_sc_id; $b = mysql_query("SELECT context_sc_id, context_role_id FROM elsa_sc_context WHERE context_sc_id = '".$edit_sc_id."'"); $roles = array(); /* pull all the roles */ while ($row = mysql_fetch_assoc($a)) { $row['selected'] = false; // create a new property $roles["_{$row['role_id']}"] = $row; } /* now loop through the context rows */ while ($row = mysql_fetch_assoc($b)) { $roles["_{$row['context_role_id']}"]['selected'] = true; // set this role as selected } var_dump($roles); ?> It might look a little longer, but.. you take it to a larger script, the benchmark will most likely be much better..
  22. PHP is server side, if you want a "take a screenshot" BUTTON for the END USER (E.G. Client/Browser, whatever) you're probably gonna want to look into some form of Java Applet or other embedable cross-platform/cross-browser objects/languages, as JavaScript cannot do this, PHP will only have access to the server end.. so what you're left with is a need to furnish the page with the functionality it needs, E.G. Embed a language that CAN do it.. I know for a fact Java Programming will allow it, given you sign it and get the proper permissions.. I did a few google searches and it seems Flash has some form of support for screenshots, but idk how good of an option it will be.. anyway, good luck!
  23. you could do this two ways, and possibly the best way first and foremost would be simply to do: SELECT role_id As id, role_name As name FROM userroles ORDER BY asc then do SELECT context_artical_id As aid, context_role_id As rid FROM context WHERE context_artical_id = 3 and you'll have all the information you need, you need to understand how mysql gets its results.. for every JOIN you're effectively calling a table scan (table scans aren't too bad, if you set indexs properly), these two functions calls only 2 table scans.. vs 1 tablescan overall + 1 tablescan per row per join.. but if you really wanted to use JOINs you could do this: SELECT a.role_id As id, a.role_name As name, IF(b.context_id,1,0) As selected FROM userroles a LEFT JOIN context b ON (b.context_role_id = a.role_id AND b.context_article_id = 3)
×
×
  • 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.