Search Results

Search found 344 results on 14 pages for 'pdo'.

Page 5/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do I install the pdo_mysql driver on Red Hat Enterprise Linux 6.1?

    - by Will Martin
    I have a RHEL box running PHP 5.3.3, which was installed using the binary packages provided by yum. I have installed the php-pdo package: # yum info php-pdo Loaded plugins: product-id, rhnplugin, subscription-manager Updating Red Hat repositories. Installed Packages Name : php-pdo Arch : x86_64 Version : 5.3.3 Release : 3.el6_1.3 Size : 168 k Repo : installed From repo : rhel-x86_64-server-6 Summary : A database access abstraction module for PHP applications URL : http://www.php.net/ License : PHP Description : The php-pdo package contains a dynamic shared object that will add : a database access abstraction layer to PHP. This module provides : a common interface for accessing MySQL, PostgreSQL or other : databases. It appears to be working correctly for SQLite databases, but not MySQL. There's no file including pdo_mysql.so in /etc/php.d, and there is no copy of pdo_mysql.so in /usr/lib64/php/modules. I'm pretty sure I just need the driver file and a line in the PHP configuration. A yum search pdo mysql didn't turn up any useful packages, and Google has failed me. If I were on Ubuntu or Debian, I'd apt-get install php5-mysql and be done with it. So ... where in Red Hat land do I get a copy of pdo_mysql.so, and install it properly?

    Read the article

  • How to enabled pdo mysql in Centos 5.8

    - by nacho3d
    I have a VPS with Centos 5.8 In phpinfo displays: './configure' '--disable-fileinfo' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-libxml' '--enable-magic-quotes' '--enable-sockets' '--prefix=/usr/local' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-curl=/opt/curlssl/' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pic' '--with-zlib' '--with-zlib-dir=/usr' I've tried this: http://www.host1free.com/forum/vps-technical-support/7248-tutoria-centos-apache-webserver-mysql-php-eaccelerator-apc.html And aparently it installed php-pdo # rpm -qa |grep php php-5.3.13-1.el5.remi php-xml-5.3.13-1.el5.remi php-common-5.3.13-1.el5.remi php-cli-5.3.13-1.el5.remi php-pdo-5.3.13-1.el5.remi php-xmlrpc-5.3.13-1.el5.remi php-mcrypt-5.3.13-1.el5.remi But I've restarted apache and it still says in my phpinfo: '--disable-pdo' Should I rebuild php? Do I need to do some other step?

    Read the article

  • How do I use pdo's prepared statement for order by and limit clauses(or can I?If not,what should I r

    - by user198729
    $sql = "SELECT * FROM table ORDER BY :sort :dir LIMIT :start, :results"; $stmt = $dbh->prepare($sql); $stmt->execute(array( 'sort' => $_GET['sort'], 'dir' => $_GET['dir'], 'start' => $_GET['start'], 'results' => $_GET['results'], ) ); I tried to use prepare to do the job,but $stmt->fetchAll(PDO::FETCH_ASSOC); returns nothing. Can someone point out what's the wrong thing I am doing?

    Read the article

  • Using PDO for Data Management

    - by edorahg
    This question is more a design oriented question than a code specific question. I am new to PHP and I am planning to use PDO as a data access layer. Say for instance I have a class called CITY. Now if I need to create an instance of this class, what is the best technique. Should have a singleton DB access class which is used to write and read data from the db layer. OR should I delegate it to the individual class object. For example if I invoke city.save() (city is a class), then the city class will handle the saving of that city object's data into the database. Excuse my ignorance but i have a java background and therefore trying to understand what is the best design principle for data management when using php.

    Read the article

  • Transforming a string to a valid PDO_MYSQL DSN

    - by Alix Axel
    What is the most concise way to transform a string in the following format: mysql:[/[/]][user[:pass]@]host[:port]/db[/] Into a usuable PDO connection/instance (using the PDO_MYSQL DSN), some possible examples: $conn = new PDO('mysql:host=host;dbname=db'); $conn = new PDO('mysql:host=host;port=3307;dbname=db'); $conn = new PDO('mysql:host=host;port=3307;dbname=db', 'user'); $conn = new PDO('mysql:host=host;port=3307;dbname=db', 'user', 'pass'); I've been trying some regular expressions (preg_[match|split|replace]) but they either don't work or are too complex, my gut tells me this is not the way to go but nothing else comes to my mind. Any suggestions?

    Read the article

  • Why do I get a PHP 5.2.6 segmentation fault when using PDO_SQlite?

    - by danieltalsky
    This is an installation on ModWest's shared hosting. I have enabled both PDO and PDO_sqlite on the server and phpinfo() verifies both are running. When I access PDO itself, I'm fine, and getting a meaningful error. <?php $dbh = new PDO(""); ?> This gives me an "Invalid Connection String" error. But, as soon as I begin a connection string with sqlite:, I get a total crash. When I run via the webserver, I'm seeing NO error. When I enter a nonexistant filename, PHP does indeed create the file. I tried running the constructor via CLI and there I do get a simple error: Segmentation Fault I'm not seeing ANYTHING in the PHP 5.2.6 changelogs about this bug. Anyone have any additional troubleshooting steps? The OS is Debian 5.0.4

    Read the article

  • Which is the correct way to use PDO in PHP?

    - by Runner
    One from here: $sth->execute(array(':calories' => $calories, ':colour' => $colour)); The other from here: /*** reassign the variables again ***/ $data = array('animal_id'=>4, 'animal_name' => 'bruce'); /*** execute the prepared statement ***/ $stmt->execute($data); My question is: :key or key ? Sorry I don't have the PHP environment here.

    Read the article

  • Php pdo_dblib - cannot find/unable to load freetds

    - by MaxPowers
    Self-hosted box, RHEL 6 PHP 5.3.3 PDO installed freetds installed pdo_dblib - so far no luck installing My goal is to use PDO with sybase. Attempting to install pdo_dblib from the appropriate version php source code. I have tried a variety of methods and searched quite a bit for help on this topic, but have yet to be successful. Method 1 Install freetds $ ./configure $ make $ su root Password: $ make install This is successful Install pdo_dblib inside the /ext/pdo_dblib folder: $ phpize $ ./configure $ make $ make test Error output: PHP Warning: PHP Startup: Unable to load dynamic library '/home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so' - /home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so' - /home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so' - /home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so' - /home/sybase/Install_items/php_533_src/php-5.3.3/ext/pdo_dblib/modules/pdo_dblib.so: undefined symbol: php_pdo_register_driver in Unknown on line 0 That doesn't look good...I researched this and found an interesting hack for this here. But changing pdo.ini to pdo_0.ini was not the solution, as I still got the same errors on make test. $ su $ make install Output: Installing shared extensions: /usr/lib64/php/modules/ That seems strange...and no, it doesn't actually install (not showing up on phpinfo after apache restart). Method 2 Install freetds following the instructions exactly, i add the prefix $ ./configure --prefix=/usr/local/freetds $ make $ su root Password: $ make install This is successful Install pdo_dblib inside the /ext/pdo_dblib folder: $ phpize $ ./configure --with-sybase=/usr/local/freetds This produces the following error at the bottom of the output ... checking for PDO_DBLIB support via FreeTDS... yes, shared configure: error: Cannot find FreeTDS in known installation directories Method 3 freetds ./configure variation (including or not include the --prefix...) did not change the result of this so I'll skip it. Install pdo_dblib pecl extension following the method specified here. pecl download pdo_dblib tar -xzvf PDO_DBLIB-1.0.tgz Removed the line, <dep type=”ext” rel=”ge” version=”1.0?>pdo</dep> Saved the package.xml file, and moved it in to the PDO_DBLIB directory. mv package.xml ./PDO_DBLIB-1.0 Navigated to the PDO_DBLIB directory, then installed the package from the directory. cd ./PDO_DBLIB-1.0 pecl install package.xml But, this command gives me the following error output, same as Method 2. checking for PDO_DBLIB support via FreeTDS... yes, shared configure: error: Cannot find FreeTDS in known installation directories ERROR: `/home/sybase/Install_items/pecl_pdo_dblib/PDO_DBLIB-1.0/configure' failed

    Read the article

  • SQL Server Driver for PHP 2.0 CTP2 is now released

    - by The Official Microsoft IIS Site
    digg_url = "http://blogs.msdn.com/b/sqlphp/archive/2010/06/15/sql-server-driver-for-php-2-0-ctp2-is-now-released.aspx";digg_title = "SQL Server Driver for PHP 2.0 CTP2 is now released";digg_bgcolor = "#FFFFFF";digg_skin = "normal"; digg_url = undefined;digg_title = undefined;digg_bgcolor = undefined;digg_skin = undefined; It is our pleasure to announce the release of Community Technology Preview 2 (CTP2) of the SQL Server Driver for PHP 2.0! We would like to...(read more)

    Read the article

  • Recursion in prepared statements

    - by Rob
    I've been using PDO and preparing all my statements primarily for security reasons. However, I have a part of my code that does execute the same statement many times with different parameters, and I thought this would be where the prepared statements really shine. But they actually break the code... The basic logic of the code is this. function someFunction($something) { global $pdo; $array = array(); static $handle = null; if (!$handle) { $handle = $pdo->prepare("A STATEMENT WITH :a_param"); } $handle->bindValue(":a_param", $something); if ($handle->execute()) { while ($row = $handle->fetch()) { $array[] = someFunction($row['blah']); } } return $array; } It looked fine to me, but it was missing out a lot of rows. Eventually I realised that the statement handle was being changed (executed with different param), which means the call to fetch in the while loop will only ever work once, then the function calls itself again, and the result set is changed. So I am wondering what's the best way of using PDO prepared statements in a recursive way. One way could be to use fetchAll(), but it says in the manual that has a substantial overhead. The whole point of this is to make it more efficient. The other thing I could do is not reuse a static handle, and instead make a new one every time. I believe that since the query string is the same, internally the MySQL driver will be using a prepared statement anyway, so there is just the small overhead of creating a new handle on each recursive call. Personally I think that defeats the point. Or is there some way of rewriting this?

    Read the article

  • Learning OOP in PHP, trying to refactor my code. Can't connect to database anymore.

    - by Cortopasta
    Thought I understood how classes work, then I tried this code: class user { var $dbcon; var $dbinfo; var $con; var $error; function dbConnect() { $this->dbinfo['server'] = "localhost"; $this->dbinfo['database'] = "foolish_faith"; $this->dbinfo['user'] = "user"; $this->dbinfo['password'] = "password"; $this->con = "mysql:host=".$dbinfo['server']."; dbname=".$dbinfo['database']; $this->dbcon = new PDO($con, $dbinfo['user'], $dbinfo['password']); $this->dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->error = $this->dbcon->errorInfo(); if ($error[0] != "") { print "Error!"; print_r($error); } } } Now it just spits out this error: Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in E:\PortableApps\xampp\htdocs\dbcon.php:24 Stack trace: #0 E:\PortableApps\xampp\htdocs\dbcon.php(24): PDO-__construct('', NULL, NULL) #1 E:\PortableApps\xampp\htdocs\login.php(4): user-dbConnect() #2 {main} thrown in E:\PortableApps\xampp\htdocs\dbcon.php on line 24 Can anybody see what I'm doing wrong, as I'm sure it has to do with my lack of knowledge when it comes to classes?

    Read the article

  • Where is my SQLite database?

    - by Brian Ramsay
    I have installed SQLite version 3 into a non-standard location on my dreamhost user account. I compiled it and installed it just fine, and it works with $db=new SQLiteDatabase("db.foont"); I can create tables and insert and read data with the SQLiteDatabase object just fine. However, I want to use PDO. My problem is that PDO requires an absolute path to the database specified in the connection. e.g., 'sqlite:/path/to/db.sq3' a) this is dumb - if the other object can figure out where the db is without an absolute path why can't PDO's sqlite driver - but that's not my question. b) where the heck is my database being stored? I can't find it anywhere in my user filesystem, and I'm pretty sure I don't have access to anything else.

    Read the article

  • PHP Connect to 4D Database

    - by Matt Reid
    Trying to connect to 4D Database. PHPINFO says PDO is installed etc etc... Testing on localhost MAMP system. However when I run my code I get: Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /Applications/MAMP/htdocs/4d/index.php:12 Stack trace: #0 /Applications/MAMP/htdocs/4d/index.php(12): PDO->__construct('4D:host=127.0.0...', 'test', 'test') #1 {main} thrown in /Applications/MAMP/htdocs/4d/index.php on line 12 My code is: $dsn = '4D:host=127.0.0.1;charset=UTF-8'; $user = 'test'; $pass = 'test'; // Connection to the 4D SQL server $db = new PDO($dsn, $user, $pass); try { echo "OK"; } catch (PDOException $e) { die("Error 4D : " . $e->getMessage()); } Can't put my finger on the error, i'm using the settings under the PHP tab... Thank you.

    Read the article

  • My $query->fetch() doesn't work

    - by Tae
    Question edited following the comments. It still doesn't work. Hi there, I'm trying to learn how PDO works, but my script: $database = new PDO('mysql:host=localhost;dbname=***', '***', '***'); $query = $database->prepare("SELECT nombre, tecnica, tamanno, estado FROM obra WHERE anno = ?"); $query->execute(array('2009')); while ($item = $query->fetch(PDO::FETCH_ASSOC)) { $item['nombre']; } Prints nothing. If I do: var_dump($query->fetch()) I get bool(false). After reading lots of examples I can't figure out what I'm doing wrong. Thanks in advance.

    Read the article

  • AWS RDS connection count

    - by wmarbut
    I am using AWS RDS with MySQL for a project and have a "large" instance. The documentation is clear on what this means as far as compute resources and RAM goes, but I can't find anything that documents how many open database connections that I can have. The app that I am using is PHP and it utilizes PDO with persistent connections. This means that the number of open connections could reach the maximum number of PHP child processes running at any given point. How do I ensure that my RDS instance has a max connections setting high enough to be comfortable with this?

    Read the article

  • How do I tell Apache which PHP to use?

    - by Sam McAfee
    I am running Apache2 on a Mac OS X (10.5). I just compiled PHP 5.2.8 and finally got pdo-mysql working (or so I think). My command line "php --version" is showing 5.2.8 and I have the right modules installed. But, when do a phpinfo(), Apache dumps out PHP 5.2.6 (my earlier version, without pdo_mysql). How do I tell Apache which PHP to load? The httpd.conf has the line: LoadModule php5_module libexec/apache2/libphp5.so But, I don't know what or where that is. Is that what I have to change?

    Read the article

  • When *not* to use prepared statements?

    - by Ben Blank
    I'm re-engineering a PHP-driven web site which uses a minimal database. The original version used "pseudo-prepared-statements" (PHP functions which did quoting and parameter replacement) to prevent injection attacks and to separate database logic from page logic. It seemed natural to replace these ad-hoc functions with an object which uses PDO and real prepared statements, but after doing my reading on them, I'm not so sure. PDO still seems like a great idea, but one of the primary selling points of prepared statements is being able to reuse them… which I never will. Here's my setup: The statements are all trivially simple. Most are in the form SELECT foo,bar FROM baz WHERE quux = ? ORDER BY bar LIMIT 1. The most complex statement in the lot is simply three such selects joined together with UNION ALLs. Each page hit executes at most one statement and executes it only once. I'm in a hosted environment and therefore leery of slamming their servers by doing any "stress tests" personally. Given that using prepared statements will, at minimum, double the number of database round-trips I'm making, am I better off avoiding them? Can I use PDO::MYSQL_ATTR_DIRECT_QUERY to avoid the overhead of multiple database trips while retaining the benefit of parametrization and injection defense? Or do the binary calls used by the prepared statement API perform well enough compared to executing non-prepared queries that I shouldn't worry about it? EDIT: Thanks for all the good advice, folks. This is one where I wish I could mark more than one answer as "accepted" — lots of different perspectives. Ultimately, though, I have to give rick his due… without his answer I would have blissfully gone off and done the completely Wrong Thing even after following everyone's advice. :-) Emulated prepared statements it is!

    Read the article

  • Listing issue, GROUP mysql

    - by SethCodes
    Here is a mock-up example of Mysql table: | ID | Country | City | ________________________________ | 1 | Sweden | Stockholm | | 2 | Sweden | Stockholm | | 3 | Sweden | Lund | | 4 | Sweden | Lund | | 5 | Germany | Berlin | | 6 | Germany | Berlin | | 7 | Germany | Hamburg | | 8 | Germany | Hamburg | Notice how both rows Country and city have repeated values inside them. Using GROUP BY country, city in my PDO query, the values will not repeat while in loop. Here is PDO for this: $query = "SELECT id, city, country FROM table GROUP BY country, city"; $stmt = $db->query($query); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : The above code will result in an output like this (some editing in-between). GROUP BY works but the country repeats: Sweden - Stockholm Sweden - Lund Germany - Berlin Germany - Hamburg Using bootstrap collapse and above code, I separate the country from the city with a simple drop down collopase. Here is code: <li> <a data-toggle="collapse" data-target="#<?= $row['id']; ?>" href="search.php?country=<?= $row['country']; ?>"> <?= $row['country']; ?> </a> <div id ="<?= $row['id']; ?>" class="collapse in"> //collapse div here <a href="search.php?city=<?= $row['city']; ?>"> <?= $row['city']; ?><br></a> </div> //end </li> It then looks something like this (once collapse is initiated): Sweden > Stockholm Sweden > Lund Germany >Berlin Germany >Hamburg Here is where I face the problem. The above lists the values Sweden and Germany 2 times. I want Sweden and Germany to only list one time, and the cities listed below, so the desired look is to be this: Sweden // Lists one time > Stockholm > Lund Germany // Lists one time >Berlin >Hamburg I have tried using DISTINCT, GROUP_CONTACT and other methods, yet none get my desired output (above). Suggestions? Below is my current full code in action: <? $query = "SELECT id, city, country FROM table GROUP BY country, city"; $stmt = $db->query($query); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : ?> <li> <a data-toggle="collapse" data-target="#<?= $row['id']; ?>" href="search.php?country=<?= $row['country']; ?>"> <?= $row['country']; ?> </a> <div id ="<?= $row['id']; ?>" class="collapse in"> //collapse div here <a href="search.php?city=<?= $row['city']; ?>"> <?= $row['city']; ?><br></a> </div> //end </li> <? endwhile ?>

    Read the article

  • Can't get php+sqlite working

    - by facha
    Hi, everyone I'm struggling all morning to make php work with an sqlite database. Here is a piece of php code that I try to execute: #less /var/www/html/test.php <?php $db=new PDO("sqlite:/var/www/test.sql"); $sql = "insert into test (login,pass) values ('login','pass');"; $db->exec($sql); ?> Here is how I've done tests: # sqlite3 /var/www/test.sql sqlite> create table test (login varchar,pass varchar); #chown apache:apache /var/www/test.sql #chmod 644 /var/www/test.sql Here is the stuff that drives me mad: When I execute from command line: #php test.php everything goes well. Sql is being executed and I can see a new row appear in the database. When I execute the same script from a browser - sql is not being executed. I don't get a new row in the database. There are no errors in the apache log file. Please, help

    Read the article

  • PHP: How to cast object to inherited class?

    - by andreyvlru
    I'd like to inherit PDOStatement class and use it in my website scripts. But I am frustrated how to get required object. PDO::query returns only direct PDOStatement object and looks like there are no other method to create PDOStatement object or inherited class. Initially i thought to move PDOStatement object to constructor of inherit class Something like that: $stmt = PDO -> query("select * from messages"); $messageCollection = new Messaging_Collection($stmt); But how to make instance of PDOStatement to inherited object (Messaging_Collection). It is a big question for me. class Messaging_Collection extends PDOStatement { public function __construct(PDOStatement $stmt) { //there i should to transform $stmt to $this // direct $this = $stmt is not possible // is there other right way? }

    Read the article

  • PHP: PDOStatement simple MySQL Select doesn't work.

    - by Alan
    Hi I have the following PHP code doing a very simple select into a table. $statement = $db->prepare("SELECT * FROM account WHERE fbid = :fbid"); $statement->bindParam(":fbid",$uid, PDO::PARAM_STR,45); $out = $statement->execute(); $row = $statement->fetch(); $out is true (success) yet $row is null. If I modify the code as follows: $statement = $db->prepare("SELECT * FROM account WHERE fbid = $uid"); $out = $statement->execute(); $row = $statement->fetch(); $row contains the record I'm expecting. I'm at a loss. I'm using the PDO::prepare(), bindParams() etc to protect against SQL Injection (maybe I'm mistaken on that). Please halp.

    Read the article

  • PHP: Proper way of using a PDO database connection in a class

    - by Cortopasta
    Trying to organize all my code into classes, and I can't get the database queries to work inside a class. I tested it without the class wrapper, and it worked fine. Inside the class = no dice. What about my classes is messing this up? class ac { public function dbConnect() { global $dbcon; $dbInfo['server'] = "localhost"; $dbInfo['database'] = "sn"; $dbInfo['username'] = "sn"; $dbInfo['password'] = "password"; $con = "mysql:host=" . $dbInfo['server'] . "; dbname=" . $dbInfo['database']; $dbcon = new PDO($con, $dbInfo['username'], $dbInfo['password']); $dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $error = $dbcon->errorInfo(); if($error[0] != "") { print "<p>DATABASE CONNECTION ERROR:</p>"; print_r($error); } } public function authentication() { global $dbcon; $plain_username = $_POST['username']; $md5_password = md5($_POST['password']); $ac = new ac(); if (is_int($ac->check_credentials($plain_username, $md5_password))) { ?> <p>Welcome!</p> <!--go to account manager here--> <?php } else { ?> <p>Not a valid username and/or password. Please try again.</p> <?php unset($_POST['username']); unset($_POST['password']); $ui = new ui(); $ui->start(); } } private function check_credentials($plain_username, $md5_password) { global $dbcon; $userid = $dbcon->prepare('SELECT id FROM users WHERE username = :username AND password = :password LIMIT 1'); $userid->bindParam(':username', $plain_username); $userid->bindParam(':password', $md5_password); $userid->execute(); print_r($dbcon->errorInfo()); $id = $userid->fetch(); Return $id; } } And if it's any help, here's the class that's calling it: require_once("ac/acclass.php"); $ac = new ac(); $ac->dbconnect(); class ui { public function start() { if ((!isset($_POST['username'])) && (!isset($_POST['password']))) { $ui = new ui(); $ui->loginform(); } else { $ac = new ac(); $ac->authentication(); } } private function loginform() { ?> <form id="userlogin" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> User:<input type="text" name="username"/><br/> Password:<input type="password" name="password"/><br/> <input type="submit" value="submit"/> </form> <?php } }

    Read the article

  • Do I really need bindParam?

    - by sandelius
    Hi there! I'm trying to do a little PDO CRUD to learn some PDO. I have a question about bindParam. Here's my update method right now: public static function update($conditions = array(), $data = array(), $table = '') { self::instance(); // Late static bindings (PHP 5.3) $table = ($table === '') ? self::table() : $table; // Check which data array we want to use $values = (empty($data)) ? self::$_fields : $data; $sql = "UPDATE $table SET "; foreach ($values as $f => $v) { $sql .= "$f = ?, "; } // let's build the conditions self::build_conditions($conditions); // fix our WHERE, AND, OR, LIKE conditions $extra = self::$condition_string; // querystring $sql = rtrim($sql, ', ') . $extra; // let's merge the arrays into on $v_val = array_values($values); $c_val = array_values($conditions); $array = array_merge($v_val, self::$condition_array); $stmt = self::$db->prepare($sql); return $stmt->execute($array); } in my "self::$condition_array" I get all the right values from the ?. SO the query looks like this: UPDATE table SET this = ?, another = ? WHERE title = ? AND time = ? as you can see I dont use bindParams instead I pass the right values in the right order ($array) directly into the execute($array) method. This works like a charm BUT is it safe not use use bindParam here? If not then how can I do it? Thanks from Sweden Tobias

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >