Search Results

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

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

  • SQL Server Driver for PHP 2.0 CTP adds PHP's PDO style data access for SQL Server

    - by The Official Microsoft IIS Site
    Today at DrupalCon SF 2010, we are reaching an important milestone by releasing a Community Technology Preview (CTP) of the new SQL Server Driver for PHP 2.0 , which includes support for PHP Data Objects (PDO). Alongside our efforts, the Commerce Guys , a company providing ecommerce solutions with Drupal, is also presenting a beta version of Drupal 7 running on SQL Server using this new PDO Application Programming Interfaces (API) in the SQL Server Driver for PHP 2.0. Providing a PDO driver in SQL...(read more)

    Read the article

  • Enable PDO for PHP5 on CentOS5 where PHP is configured as '--disable-pdo'

    - by jakenoble
    Hi I have been given access to a CentOS5 machine by my client for their new site which uses Zend Framework. phpinfo() states in Configure Command that PDO is disabled ('--disable-pdo'). How can enable it? Do I need to recompile PHP5 to enable it? I have tried adding 'extension=pdo.so' in php.ini and restarting Apache, but this didn't work. It would also be nice to understand what '--disable-pdo' actaully means, does it mean it's not compiled into PHP or does it mean its just not enabled? Thanks for your time

    Read the article

  • PDO::fetchAll vs. PDO::fetch in a loop

    - by Byron
    Just a quick question. Is there any performance difference between using PDO::fetchAll() and PDO::fetch() in a loop (for large result sets)? I'm fetching into objects of a user-defined class, if that makes any difference. My initial uneducated assumption was that fetchAll might be faster because PDO can perform multiple operations in one statement while mysql_query can only execute one. However I have little knowledge of PDO's inner workings and the documentation doesn't say anything about this, and whether or not fetchAll() is simply a PHP-side loop dumped into an array. Any help?

    Read the article

  • getting PHP PDO flavors to work on Mac OS X

    - by Jason S
    I'm running OS X 10.5; it looks like it came with Apache and PHP installed (minus some minor configurations which I turned on per this page; I've used Apache before so I know the basics of how httpd.conf works). I've got a pre-existing script which uses PDO. I've got a MySQL database and can easily configure my script to access the database via PDO MySQL or PDO ODBC. The problem is, that even though I enabled the PDO MySQL and PDO ODBC extensions in php.ini, phpinfo() reports the only PDO drivers are sqlite2 and sqlite. I'm guessing the relevant extension .dll or .so files are not present? How do I get them? note: I'm using the built-in install for PHP. (see apple's page on enabling php, which doesn't say anything about configure or adding additional .so files)

    Read the article

  • Can't get PDO MySQL driver to work on PHP

    - by bart
    Trying to install Vanilla 2 locally using MAMP i got the error: "You must have the MySQL driver for PDO enabled in order for Vanilla to connect to your database". When I check phpinfo() I see: --with-pdo-mysql=shared,/Applications/MAMP/Library --with-pdo-pgsql=shared,/Applications/MAMP/Library/pg When I go and check out those paths I find the files: libpq.5.dylib libpq.dylib libpq.5.2.dylib When I check my php.ini file I see: ; Extensions extension=pdo_mysql.so In php.ini the path to the extension dir is correct (checked it manually): extension_dir = "/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/" In this folder I find the file: pdo_mysql.so phpinfo() gives me two sections: PDO PDO drivers: sqlite, sqlite2 and pdo_sqlite SQLite Library: 3.6.22 So everything seems to be fine, but can't get the PDO MySQL driver working :(

    Read the article

  • Can't get PDO MySQL driver to work on PHP

    - by bart
    Trying to install Vanilla 2 locally using MAMP i got the error: "You must have the MySQL driver for PDO enabled in order for Vanilla to connect to your database". When I check phpinfo() I see: --with-pdo-mysql=shared,/Applications/MAMP/Library --with-pdo-pgsql=shared,/Applications/MAMP/Library/pg When I go and check out those paths I find the files: libpq.5.dylib libpq.dylib libpq.5.2.dylib When I check my php.ini file I see: ; Extensions extension=pdo_mysql.so In php.ini the path to the extension dir is correct (checked it manually): extension_dir = "/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/" In this folder I find the file: pdo_mysql.so phpinfo() gives me two sections: PDO PDO drivers: sqlite, sqlite2 and pdo_sqlite SQLite Library: 3.6.22 So everything seems to be fine, but can't get the PDO MySQL driver working :(

    Read the article

  • Trying to install pdo_oci via PECL fails asking for PDO extension

    - by Igoru
    I'm using Linux Mint 11 (based on Ubuntu 11.04) and I need to use PHP with Oracle through PDO, a requirement of the framework we will work with. I've installed various PDO extensions using the normal apt-get method, like php5-mysql, etc, and they loaded just fine, along with the initial PDO extension. But there's no package for Oracle bindings. So, when I try to run sudo pecl install pdo_oci it throws me this: WARNING: "pear/PDO_OCI" is deprecated in favor of "channel://http://www.php.net/pdo_oci/ext/pdo_oci" pear/PDO_OCI requires PHP extension "pdo" (version >= 1.0) No valid packages found install failed How can I add this channel, or is there a better way to install the PDO_OCI extension?

    Read the article

  • How to use sessions in PDO?

    - by Byakugan
    I am still redoing and getting rid of old mysql_* commands in my code. I tried to transfer my session login form old code and this is what I got so far: public function login($user, $password) { if (!empty($user) && !empty($password)) { $password = $web->doHash($user, $password); // in this function is (return sha1(strtoupper($user).':'.strtoupper($password)) $stmt = $db_login->prepare("SELECT * FROM account WHERE username=:user AND pass_hash=:password"); $stmt->bindValue(':user', $user, PDO::PARAM_STR); $stmt->bindValue(':password', $password, PDO::PARAM_STR); $stmt->execute(); $rows = $stmt->rowCount(); if ($rows > 0) { $results_login = $stmt->fetch(PDO::FETCH_ASSOC); $_SESSION['user_name'] = $results_login['username']; $_SESSION['user_id'] = $results_login['id']; return true; } else { return false; } } else { return false; } } After that I am using checks if user logged on site: public function isLogged() { return (!empty($_SESSION['user_id']) && !empty($_SESSION['user_name'])); } But it seems - this function returns always empty because $_SESSION does not exists in PDO? And of course logout is used in this form on my sites: public function logout() { unset($_SESSION['user_id']); unset($_SESSION['user_name']); } But I think PDO has different way of handling session? I did not find any so what is it can i somehow add $_SESSION in PDO withou changing code much? I am using variables $_SESSION['user_name'] and $_SESSION['user_id'] in all over my web project. Summary: 1) How to use sessions in PDO correctly? 2) What is difference between using $stmt->fetch(PDO::FETCH_ASSOC); and $stmt->fetchAll(); Thank you.

    Read the article

  • Converted PHP query to PDO and now getting no results

    - by jaw
    I had a query working just fine, but after converting it to PDO I am getting no results when I do a var_dump($row). But there are no error messages. Can anyone see what I might be doing wrong? //Here is the original query that worked fine and returned results global $wpdb; $results = $wpdb->get_results("SELECT stories.story_name, stories.category, stories.SID, wp_users.ID, wp_users.display_name FROM stories LEFT JOIN wp_users ON stories.ID=wp_users.ID where stories.active = 1"); //Here is the query in PDO form which returns no results $results = $dbh->prepare("select wp_users.ID, wp_users.display_name, stories.SID, stories.story_name, stories.category, FROM stories LEFT JOIN wp_users ON stories.ID=wp_users.ID WHERE stories.active=1"); $results->bindParam(':wp_users.ID', $user_ID, PDO::PARAM_INT); $results->bindParam(':display_name', $display_name, PDO::PARAM_STR); $results->bindParam(':stories.SID', $SID, PDO::PARAM_INT); $results->bindParam(':story_name', $story_name, PDO::PARAM_STR); $results->bindParam(':category', $category, PDO::PARAM_STR); $results->execute(); $row = $results->fetchAll(PDO::FETCH_ASSOC); //returns 0 results but should return 8 as original code above did echo var_dump($row);

    Read the article

  • Error when trying to use PDO object

    - by Nate
    EDIT: I'm going to put my code in here due to comments below. So sit tight for a few minutes ;-) Thanks! I'm an inexperienced php programmer and only found out about PDO a few days ago. I'm now trying to port my website code over to using PDO, but I am getting an error when I try to use the PDO object that I create. I'm using a CMS on my website, and it makes building page output kind of complicated, but I've tried to draw the structure of what is being called below: index.php -class myClass defined --method myFunction defined (it gets called on pageload & returns the page output) ---include file1.php ----require_once('mysql_connect.php') (creates pdo object) ----*I can use the pdo object here successfully* ----require_once('file2.php') -----require_once('mysql_connect.php') -----function myFunction2 defined ------*trying to use the pdo object here results in the error* The error I'm getting is: Fatal error: Call to a member function prepare() on a non-object in /home/rgcpanel/public_html/account/account_functions.php on line 147 Any idea what's going on?

    Read the article

  • PDO prepare silently fails

    - by Wabbitseason
    I'm experimenting with PHP's session_set_save_handler and I'd like to use a PDO connection to store session data. I have this function as a callback for write actions: function _write($id, $data) { logger('_WRITE ' . $id . ' ' . $data); try { $access = time(); $sql = 'REPLACE INTO sessions SET id=:id, access=:access, data=:data'; logger('This is the last line in this function that appears in the log.'); $stmt = $GLOBALS['db']->prepare($sql); logger('This never gets logged! :('); $stmt->bindParam(':id', $id, PDO::PARAM_STR); $stmt->bindParam(':access', $access, PDO::PARAM_INT); $stmt->bindParam(':data', $data, PDO::PARAM_STR); $stmt->execute(); $stmt->closeCursor(); return true; } catch (PDOException $e) { logger('This is never executed.'); logger($e->getTraceAsString()); } } The first two log messages always show up, but the third one right after $stmt = $GLOBALS['db']->prepare($sql) never makes it to the log file and there's no trace of an exception either. The sessions db table remains empty. The log message from the _close callback is always present. Here's how I connect to the database: $db = new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASS); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); I have PHP 5.2.10. I tried to simply run $GLOBALS['db']->exec($sql) with a "manually prepared" $sql content, but it still failed silently. The query itself is all right I was able to execute it via the db console.

    Read the article

  • PDO::PARAM for type decimal?

    - by dmontain
    I have 2 database fields `decval` decimal(5,2) `intval` int(3) I have 2 pdo queries that update them. The one that updates the int works ok $update_intval->bindParam(':intval', $intval, PDO::PARAM_INT); but I can't update the decimal field. I've tried the 3 ways below, but nothing works $update_decval->bindParam(':decval', $decval, PDO::PARAM_STR); $update_decval->bindParam(':decval', $decval, PDO::PARAM_INT); $update_decval->bindParam(':decval', $decval); It seems the problem is with the database type decimal? Is there a PDO::PARAM for a field of type decimal? If not, what do I use as a workaround?

    Read the article

  • Is SQL used by PDO database independent?

    - by Pheter
    Different databases have slight variations in their implementations of SQL. Does PDO handle this? If I write an SQL query that I use with PDO to access a MySQL database, and later tell PDO to start using a different type of database, will the query stop working? Or will PDO 'convert' the query so that it continues to work? If PDO does not do this, are there any PHP libraries that allow me to write SQL according to a particular syntax, and then the library will handle converting the SQL so that it will run on different databases?

    Read the article

  • PDO::ATTR_EMULATE_PREPARES => false

    - by user264058
    I'm new to php and PDO ,so i read this response to a similar post- Does PDO really not use prepared statements with mysql? Yes, by default (at least with version I tested) but native mode can be turned on manually. If not, can it be forced to do so By employing PDO::ATTR_EMULATE_PREPARES setting, the name is pretty self-explanatory. $dbh-setAttribute( PDO::ATTR_EMULATE_PREPARES, false ); should you do that? That's hardest question of them all. Well, I'd say - yes, you should. If you choose PDO as your db driver, there is no point in using it in the emulation mode. by YOUR COMMON SENSE Aren't prepared statements secure from SQL injection, why change if from 'true'-false?? what is native mode??

    Read the article

  • Call to undefined function query() - using PDO in PHP

    - by webworm
    I have a written a script in PHP that reads from data from a MySQL database. I am new to PHP and I have been using the PDO library. I have been developing on a Windows machine using the WAMP Server 2 and all has been working well. However, when I uploaded my script to the LINUX server where it will be used I get the following error when I run my script. Fatal error: Call to undefined function query() This is the line where the error is occuring ... foreach($dbconn->query($sql) as $row) The variable $dbconn is first defined in my dblogin.php include file which I am listing below. <?php // Login info for the database $db_hostname = 'localhost'; $db_database = 'MY_DATABASE_NAME'; $db_username = 'MY_DATABASE_USER'; $db_password = 'MY_DATABASE_PASSWORD'; $dsn = 'mysql:host=' . $db_hostname . ';dbname=' . $db_database . ';'; try { $dbconn = new PDO($dsn, $db_username, $db_password); $dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo 'Error connecting to database: ' . $e->getMessage(); } ?> Inside the function where the error occurs I have the database connection defined as a superglobal as such ... global $dbconn; I am a bit confused as to what is happening since all worked well on my development machine. I was wondering if the PDO library was installed but from what I thought it was installed by default as part of PHP v5. The script is running on an Ubuntu (5.0.51a-3ubuntu5.4) machine and the PHP version is 5.2.4. Thank you for any suggestions. I am really lost on this.

    Read the article

  • PHP PDO bindValue() weird problem

    - by TheMagician
    <?php try { $db = new PDO("mysql:host=localhost;dbname=DBNAME", "USER", "PASSWD"); $stmt = $db->prepare("SELECT id, name FROM testdb ORDER BY time DESC LIMIT :index, 10"); $stmt->bindValue(":index", $_GET['index'], PDO::PARAM_INT); $stmt->execute(); while( $r = $stmt->fetch(PDO::FETCH_ASSOC) ) { echo var_dump($r); } } catch( PDOException $e ) { die("Exception"); } The problem is on this line: $stmt-bindValue(":index", $_GET['index'], PDO::PARAM_INT); And the specific parameter is the second one. The code as it is above doesn't work, it doesn't return anything so the while loop isn't executed. If I replace $_GET['index'] with a number, like 10, it works just fine, it returns 10 rows. Echoing $_GET['index'] displays a number, so it should pass a number. I've also tried bindParam, but the result is same. Why isn't this working?

    Read the article

  • PDO/Oracle vs OCI

    - by jarcoal
    The company I work for currently uses some basic functions to abstract the OCI libraries as a means for DB connectivity. We're considering switching to PHP's PDO object, but from some quick searches, it looks like the Oracle driver is a bit less mature than the other PDO drivers. I would appreciate some pro/cons for PDO/Oracle from anyone who has used it in a production environment. Thanks!

    Read the article

  • How to avoid this PDO exception: Cannot execute queries while other unbuffered queries are active

    - by Vittorio Vittori
    Hi, I'd like to print a simple table in my page with 3 columns, building name, tags and architecture style. If I try to retrieve the list of building names and arch. styles there is no problem: SELECT buildings.name, arch_styles.style_name FROM buildings INNER JOIN buildings_arch_styles ON buildings.id = buildings_arch_styles.building_id INNER JOIN arch_styles ON arch_styles.id = buildings_arch_styles.arch_style_id LIMIT 0, 10 My problem starts on retreaving the first 5 tags for every building of the query I've just wrote. SELECT DISTINCT name FROM tags INNER JOIN buildings_tags ON buildings_tags.tag_id = tags.id AND buildings_tags.building_id = 123 LIMIT 0, 5 The query itself works perfectly, but not where I thought to use it: <?php // pdo connection allready active, i'm using mysql $pdo_conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); $sql = "SELECT buildings.name, buildings.id, arch_styles.style_name FROM buildings INNER JOIN buildings_arch_styles ON buildings.id = buildings_arch_styles.building_id INNER JOIN arch_styles ON arch_styles.id = buildings_arch_styles.arch_style_id LIMIT 0, 10"; $buildings_stmt = $pdo_conn->prepare ($sql); $buildings_stmt->execute (); $buildings = $buildings_stmt->fetchAll (PDO::FETCH_ASSOC); $sql = "SELECT DISTINCT name FROM tags INNER JOIN buildings_tags ON buildings_tags.tag_id = tags.id AND buildings_tags.building_id = :building_id LIMIT 0, 5"; $tags_stmt = $pdo_conn->prepare ($sql); $html = "<table>"; // i'll use it to print my table foreach ($buildings as $building) { $name = $building["name"]; $style = $building["style_name"]; $id = $building["id"]; $tags_stmt->bindParam (":building_id", $id, PDO::PARAM_INT); $tags_stmt->execute (); // the problem is HERE $tags = $tags_stmt->fetchAll (PDO::FETCH_ASSOC); $html .= "... $name ... $style"; foreach ($tags as $current_tag) { $tag = $current_tag["name"]; $html .= "... $tag ..."; // let's suppose this is an area of the table where I print the first 5 tags per building } } $html .= "...</table>"; print $html; I'm not experienced on queries, so i though something like this, but it throws the error: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. What can I do to avoid this? Should I change all and search a different way to get this kind of queries?

    Read the article

  • PDO bindparam not working.

    - by jim
    I am trying to save data into a database using PDO. All columns save correctly with the exception of one. No matter what I try, I cannot get the data to go in. myfunc($db, $data) { echo $data; // <----- Outputs my data. example: 'jim jones' $stmt = $db->prepare("CALL test(:id, :data, :ip, :expires)"); $stmt->bindParam(':id', $id, PDO::PARAM_STR); $stmt->bindParam(':data', $data, PDO::PARAM_STR); $stmt->bindParam(':ip', $ip, PDO::PARAM_STR); $stmt->bindParam(':expires', $expires, PDO::PARAM_STR); ... } So even after verifying that the data variable in fact holds my data, the bindParam method will not bind. When I echo the data variable, I can see the data is there. It will not save though. If I copy the echo'd output of the data variable to screen and paste it into a new variable, it WILL save. I'm at this now for a couple of hours. Can someone please have a look? EDIT: I want to also mention that I have tried using bindValue() in place of bindParam() and the data for the data variable will still not save.

    Read the article

  • Binding a date string parameter in an MS Access PDO query

    - by harryg
    I've made a PDO database class which I use to run queries on an MS Access database. When querying using a date condition, as is common in SQL, dates are passed as a string. Access usually expects the date to be surrounded in hashes however. E.g. SELECT transactions.amount FROM transactions WHERE transactions.date = #2013-05-25#; If I where to run this query using PDO I might do the following. //instatiate pdo connection etc... resulting in a $db object $stmt = $db->prepare('SELECT transactions.amount FROM transactions WHERE transactions.date = #:mydate#;'); //prepare the query $stmt->bindValue('mydate', '2013-05-25', PDO::PARAM_STR); //bind the date as a string $stmt->execute(); //run it $result = $stmt->fetch(); //get the results As far as my understanding goes the statement that results from the above would look like this as binding a string results in it being surrounded by quotes: SELECT transactions.amount FROM transactions WHERE transactions.date = #'2013-05-25'#; This causes an error and prevents the statement from running. What's the best way to bind a date string in PDO without causing this error? I'm currently resorting to sprintf-ing the string which I'm sure is bad practise. Edit: if I pass the hash-surrounded date then I still get the error as below: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22018]: Invalid character value for cast specification: -3030 [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. (SQLExecute[-3030] at ext\pdo_odbc\odbc_stmt.c:254)' in C:\xampp\htdocs\ips\php\classes.php:49 Stack trace: #0 C:\xampp\htdocs\ips\php\classes.php(49): PDOStatement-execute() #1 C:\xampp\htdocs\ips\php\classes.php(52): database-execute() #2 C:\xampp\htdocs\ips\try2.php(12): database-resultset() #3 {main} thrown in C:\xampp\htdocs\ips\php\classes.php on line 49

    Read the article

  • how to have defined connection within function for pdo communication with DB

    - by Scarface
    hey guys I just started trying to convert my query structure to PDO and I have come across a weird problem. When I call a pdo query connection within a function and the connection is included outside the function, the connection becomes undefined. Anyone know what I am doing wrong here? I was just playing with it, my example is below. include("includes/connection.php"); function query(){ $user='user'; $id='100'; $sql = 'SELECT * FROM users'; $stmt = $conn->prepare($sql); $result=$stmt->execute(array($user, $id)); // now iterate over the result as if we obtained // the $stmt in a call to PDO::query() while($r = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "$r[username] $r[id] \n"; } } query();

    Read the article

  • how have defined connection within function for pdo communication with DB

    - by Scarface
    hey guys I just started trying to convert my query structure to PDO and I have come across a weird problem. When I call a pdo query connection within a function and the connection is included outside the function, the connection becomes undefined. Anyone know what I am doing wrong here? I was just playing with it, my example is below. include("includes/connection.php"); function query(){ $user='user'; $id='100'; $sql = 'SELECT * FROM users'; $stmt = $conn->prepare($sql); $result=$stmt->execute(array($user, $id)); echo $count=$stmt->rowCount(); if (!$result || $stmt->rowCount()>=1){ echo 'balls'; } // now iterate over the result as if we obtained // the $stmt in a call to PDO::query() while($r = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "$r[username] $r[id] \n"; } } query();

    Read the article

  • Datetime NOW PHP mysql (+ PDO variant)

    - by Chris
    Thanks for looking. All helpful answers/comments are up voted. In php, you can use NOW() like this: mysql_query("INSERT INTO tablename (id, value, time_created) VALUES ('{$id}', '{$value}', NOW())"); How can I do the same thing in PDO. When I bind like this, I get an error: $stmt->bindParam(':time_added', NOW(), PDO::PARAM_STR); Is it the PDO:PARAM_STR?

    Read the article

  • PDO empy result from SELECT when using AND

    - by Jurgen
    Hello, I've come upon a rather interesting thing, which I can't seem to figure out myself. Everytime when executing a SQL statement which contains a '... AND ...' the result is empty. Example: echo('I have a user: ' . $email . $wachtwoord . '<br>'); $dbh = new PDO($dsn, $user, $password); $sql = 'SELECT * FROM user WHERE email = :email AND wachtwoord= :wachtwoord'; $stmt = $dbh->prepare($sql); $stmt->bindParam(:email,$email,PDO::PARAM_STR); $stmt->bindParam(:wachtwoord,$wachtwoord,PDO::PARAM_STR); $stmt->execute(); while($row = $stmt->fetchObject()) { echo($row-email . ',' . $row-wachtwoord); $user[] = array( 'email' = $row-email, 'wachtwoord' = $row-wachtwoord ); } The first echo displays the correct values, however the line with echo($row->email . ',' . $row->wachtwoord); is never reached. A few things I want to add: 1) I am connected to the database since other queries work, only the ones where I add an 'AND' after my 'WHERE's fail. 2) Working with the while works perfectly with queries that do not contain '... AND ...' 3) Error reporting is on, PDO gives no exceptions on my query (or anything else) 4) Executing the query directly on the database does give what I want: SELECT * FROM user WHERE email = '[email protected]' AND wachtwoord = 'jurgen' I can stare at it all day long again (which I already did once, but I managed to work around the 'AND'), but maybe one of you can give me a helping hand. Thank you in advance. Jurgen

    Read the article

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