MDB2 placeholder shorthand with DB->query

I just realized that the pear:DB extension is deprecated and I'm working on updating some scripts to MDB2. I'm a little disappointed how cumbersome the placeholder arrangement is. Am I missing something? Is there a shorthand available that is equivalent to the pear:DB construct:

$result = $db->query("SELECT * FROM table WHERE column1 = ? AND column2 = ?", array($column1, $column2);

As far as I can tell, achieving the same result (no pun intended) would require several lines and a call to MDB2-prepare(), MDB2->execute() etc....

Is any shorthand construct available for MDB2?

-------------Problems Reply------------

No, there is none. You have to use prepare() + execute().

Category:php Views:1 Time:2011-05-17
Tags: php sql pear mdb2

Related post

  • SQL UNION Query with Extra Field in Results 2011-05-01

    I have a SQL query that is working well except I would like to bring the results of another column in the first db with it. This is what I currently have: SELECT parts1.PART_NBR, parts1.NIIN FROM parts1 WHERE parts1.PART_NBR='$pn' UNION SELECT parts2

  • In SQL Server, how do I generate a CREATE TABLE statement for a given table? 2008-08-22

    I've spent a good amount of time coming up with solution to this problem, so in the spirit of this post, I'm posting it here, since I think it might be useful to others. If anyone has a better script, or anything to add, please post it. Edit: Yes guy

  • How do you manage SQL Queries 2008-09-01

    At the moment my code (PHP) has too many SQL queries in it. eg... // not a real example, but you get the idea... $results = $db->GetResults("SELECT * FROM sometable WHERE iUser=$userid"); if ($results) { // Do something } I am looking into using s

  • What are the advantages/disadvantages of using a CTE? 2008-09-10

    I'm looking at improving the performance of some SQL, currently CTEs are being used and referenced multiple times in the script. Would I get improvements using a table variable instead? (Can't use a temporary table as the code is within functions). -

  • Parameter naming using System.Data.Common 2009-08-10

    This is probably an oldie-but-goodie. I am using System.Data.Common for an interchangeable Oracle/SQL Server/SQLite data access library. During the constructor I take the connection string name and use that to determine the underlying provider type.

  • LINQ queries: SQL-style abbreviations or spell it out? 2009-12-31

    Microsoft is pretty clear that .NET "identifiers" or "parameters" should not contain abbreviations. Straight from the horse's mouth: To avoid confusion and guarantee cross-language interoperation, follow these rules regarding the use of abbreviations

  • What kind of syntax is this in PHP? 2010-01-17

    if(true): echo 'good'; endif; I've only see it in PHP today! I've always been using: if(true) { echo 'good'; } --------------Solutions------------- It is the Alternative syntax for control structures. Quoting that page of the manual : PHP offers an a

  • How do search engines see dynamic profiles? 2010-06-02

    Recently search engines have been able to page dynamic content on social networking sites. I would like to understand how this is done. Are there static pages created by a site like Facebook that update semi frequently. Does Google attempt to store e

  • Is there a way to get large thumbnails of videos I have posted from Facebook? 2011-01-19

    I'm trying to get large video thumbnails via FQL or the Graph Api. When I request a thumbnail I get: I randomly noticed today though that if you ch

  • Django .save() Reverts 2011-05-23

    I have an InteferField set in models called the status. I have a method that is two switch the value of two rows statuses. Row one -> status = 1 Row two -> status = 2 Now, I figure, if I switch row one's status to some unattainable reach (99) I

  • Why is CTE better than cursor/derived table/ subqueries/ temp table etc.? 2011-07-26

    How and why CTE gives a better performance as compared to derived table/ subqueries/ temp table etc. approaches? Any temporary calculations happens in the temporary database. So if we have a cursor approach, it also creates temporary table/work table

  • When are (SELECT) queries planned? 2012-02-14

    In PostgreSQL, when are (SELECT) queries planned? Is it: at statement-prepare time, or at the start of processing the SELECT, or something else The reason I ask is that there is a Stackoverflow question: same query, two different ways, vastly differe

  • ng-repeat Circular Reference Screen Refresh 2014-07-21

    I'm a noob to AngularJS. As a learning exercise I am creating a typeahead control. The typeahead is comprised of a text box for filtering the options, an unordered list for displaying the menu of short-listed options, and a Show/Hide button for manua

  • DBD::SQLite, how to pass array in query via placeholder? 2011-04-09

    Let's have a table: sqlite> create table foo (foo int, bar int); sqlite> insert into foo (foo, bar) values (1,1); sqlite> insert into foo (foo, bar) values (1,2); sqlite> insert into foo (foo, bar) values (1,3); Then SELECT some data: sql

  • Doctrine query doesn't recognize shorthand: building condition based queries 2011-07-13

    public static function getAuctions($other = false) { $q = Doctrine::getTable('auctions') ->createQuery('u') ->select('TIMEDIFF(ends_at, NOW()) as time, ur.username as username, u.last_bider as last_bider, pr.img_path as img_path, u.curr_price a

  • Rails. How to remove quotation marks from query conditions when using a placeholder and string? 2012-01-18

    I'm trying to create a search form (rails 3.1) where one of the search parameters allows the user to pick math symbols like <, >, = etc. I then want to use the value chosen as part of my query. The only problem is it puts quotation marks around

  • MDB2 autoprepare problem 2010-11-08

    I am using mdb2 for my website and i ran into a problem. I have an order_no field in my table that i would like to have a default value like LAST_INSERT_ID() + 1. Is there a datatype that can be set for this kind of mysql functions for mdb2->autoE

  • What does the "?" mean in a query? 2010-12-15

    In the following query, what does "?" mean? this.AdminDelCmd.CommandText = "DELETE FROM Admin WHERE (admincd = ?) AND (terminalno = ?)"; --------------Solutions------------- This is NOT a ternary operator, and is NOT an object of type Nullable. This

  • Understanding a MySQL query 2011-11-09

    I've been seeing queries like the one below more commonly now than ever. What I'm lost at is 'p.title', the 'as' clause, and 'FROM Posts p'. Anybody care to explain these parts to me or refer me to resources as I have no clue what to search for in Go

Copyright (C), All Rights Reserved.

processed in 0.172 (s). 11 q(s)