Jump to content

john_c_1984

Members
  • Posts

    11
  • Joined

  • Last visited

john_c_1984's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. http://forums.phpfreaks.com/topic/285929-pdo-in-a-php-class/#post_id_1467894 Try this if you are using pdo. Returns a nice array already counted for you..
  2. Technically you are calling an undefined function, then declaring the function. Try declaring the funciton first then calling it?
  3. Can you use event listeners and jQuery? If so then this could work <input type="radio" name="toasted" id="toasted_sandwiches" value="Toasted Sandwiches"/> <input type="radio" name="toasted" id="toasted_paninis" value="Toasted Paninis"/> <script type="text/javascript"> $(document).ready(function(){ $( 'input[type=radio][name=toasted]' ).click(function(){ if( $(this).prop('selected') ){ switch( $(this).attr('id') ){ case 'toasted_sandwiches': var spry_toasted_sandwiches = new Spry.Widget.ValidationCheckbox("spry_toasted_sandwiches", {minSelections:3, validateOn:["change", "blur"]}); break; case 'toasted_sandwiches': var spry_paninis = new Spry.Widget.ValidationCheckbox("spry_paninis", {minSelections:3, validateOn:["change", "blur"]}); break; } } }); }); </script>
  4. http://jsfiddle.net/Q5AjL/ I am getting a strange affect in internet explorer. When I apply rounded corners the elements corners become broken. I thought it might be something to do with my html page, the doc type etc... but when isolating the css into a jsfiddle i get the same results. Has anyone else come accross this? I currently have ie11. When i put ie 11 into developer mode the issue vanishes! So confusing. I have attached some screen shot examples. This is making the site look like it has some sort of desease..
  5. Sorry gizmola i realised i never actually got around to replying. I just meant with amazon.. they are just another evil corp dodging taxes like its dodge ball thus further weakening each countries economy they leach within, whilst simulateously screwing over their staff; treating them like minions and discarding without a shred of emotion or empathy. I believe that companies like Amazon are evil to the core and should be avoided. Spend a pound in your local shop and you are putting money back into your community where as spend a pound on amazon and you are doing the opposite. I often wonder how any countries governement lets this sort of tax dodging persist.. but then corruption has deep roots i guess. (i could not find a spell check on this wysiwyg editor so please pardon my terrible spelling)
  6. Thanks very much for all your opinions guys! Very much appreciated Lots of info to go on here!
  7. tabs are the main sticking point on yml for most people
  8. Really? Supporting the devil there... I do know a few who prefer centOS. Never used it before, are there any key differences to that and Debian?
  9. It is good for a quick fire answer if you are too swamped to dig around for the answer yourself, even if no answer comes from the responses you get a general feel and know what to query the googlebots. Their ranking/ pointing system i think really gets people hooked on replying as fast as possible, which is great for me Yea, i am getting little smirks here and there when i say to people i am running ubuntu as a servers.. it was making me wonder. Debian does seem to a be taking the lead...
  10. Although I do myself now use Symfony and Doctrine and would highly recomend this to anyone. I did write a simple PDO layer for ease of use (when i was rolling my own).. reduced the amount of code I had to write all the time (this forum editor and my editor don't agree so the spacing seems a little ott but you get the picture) //***** in a database class file*****/ namespace yourproject; class Database { private $db_con = ''; /*** Function to login to the database ***/ public function db_login() { // Try to connect try{ // Retrieve the login details require_once WEBROOT_PRIVATE.'logins/General_login.php'; // Connect to the server and select database $this->db_con = new \PDO("mysql:host=$db_hostname;dbname=$db_database", "$db_username", "$db_password", array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); // Prevent emulation of prepared statements for security $this->db_con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); $this->db_con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return true; } // If it fails, send user to maintenance page catch(PDOException $e) { header("location:$_WEBROOT/maintenance.php"); exit(); } } /*** Function for database control ***/ public function db_control($query , $parameters, $returnID = false) { if(!is_array($query) && is_array($parameters)) { try{ //prepare the statement $statement = $this->db_con->prepare($query); //execute the statement $statement->execute($parameters); //check whether this is a select, if it is then we need to retrieve the selected data if(strpos($query, 'SELECT') !== false) { //fetch the results $result = array(); while( $row = $statement->fetch(\PDO::FETCH_ASSOC) ) { $result[] = $row; } //count the results $count = count($result); //return the array return array( 'results' => $result, 'result_count' => $count ); } //else return the number of affected rows else{ //count the affected rows and place into a returnable array $affected_rows = $statement->rowCount(); $returnArray = array('result_count' => $affected_rows); //check to see if we are to return a newly inserted autoincrement ID from an INSERT if($returnID) { //find the newly created ID and add this data to the return array $insertID = $this->db_con->lastInsertId(); $returnArray['ID'] = $insertID; } return $returnArray; } } catch(PDOException $e) { return false; } } else{ return false; } } } //***** Place this in a global functions file ********// // Start the database class and connect to the database $db = new \yourproject\Database(); $db->db_login(); function _db( $sql , $params , $returnID = false ){ return $GLOBALS['db']->db_control( $sql , $params , $returnID ); } //*****From anywhere in your project ******// //then plonk any sql query in like so (as you have declared the db_control from the class as a global function) from anywhere in your application. $sql = 'SELECT ID FROM user WHERE name=:name'; $params = array(':name' => 'Bill Gates'); $query = _db($sql, $params); //the $query is now an assoc array with 'results' and 'result_count'.. extend accordingly. In particular, i wouldn't bother bind the values individually (see inside the db_control function): //prepare the statement $statement = $this->db_con->prepare($query); //execute the statement $statement->execute($parameters);
  11. Hi, I used to be a member of this forum a few years ago but forgot my username and password so created a fresh. I went to SO for a while but then I miss the general conversations you get in a proper forum. Anyway, I have had a dig around in this forums history and cannot see any threads directly related to which are peoples prefered production server os. http://www.techrepublic.com/blog/10-things/10-differences-between-linux-and-bsd/ I am currently deliberating between linux and bsd but cannot choose. I currently have a handfull of servers running Ubuntu 12 lts, however at the time of choosing Ubuntu i was greener than grass in the world of developing and the decision making process, which was most popular on google search. Is freebsd dead dying? As a production server all i am looking for is speed & stability in running a JAMP setup (the J being java). I do some work with with eZ Publish to which their recomendation is Debian 7 (https://confluence.ez.no/display/EZP52/Requirements) but then I know people working with eZ who live by freeBSD. What are people opinions and why? (but then you read articles like this http://aboutthebsds.wordpress.com/2012/12/23/the-current-state-of-freebsd/)
×
×
  • 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.