473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Is this a MySQLi function?

Samishii23
246 100+
Hmm. I've found a code example, mind you from 2005 so it's probably out of date on its own... But I was wondering about it, and haven't been able to find it on PHP's document site.

I know using the ?'s is used in Prepared Statements, but I was wondering if this code block is still possible in current versions
Expand|Select|Wrap|Line Numbers
  1. $sql = 'INSERT INTO user (username,passwordHash) VALUES (?,?)';
  2. $result = $db->query($sql, array($_POST['username'], $passwordHash));
Link. First code block.
Link
Aug 27 '10 #1

✓ answered by Dormilich

not sure about MySQLi, but you can pass an array of parameters directly to PDOStatement->execute(), although this implies the values to be strings (i.e. as type parameter, PDO::PARAM_STR will be passed, regardless whether that is true for the data type or the DB field type)

and to answer the question directly, you can pass your values like the guy in the article, though that requires you to write the appropriate Database Abstraction Layer (classes).

4 1373
Dormilich
8,658 Expert Mod 8TB
this code is at least nothing native to PHP, as both in MySQLi and PDO, Prepared Statements are invoked by ->prepare() and executed by ->execute(), you may bind the values before calling execute().

there is no information about the nature of the $db object (which is only meant for illustration), as the focus of the article was password hashing.
Aug 28 '10 #2
Samishii23
246 100+
I understand, I was just hoping that I would be able to pass the parameters the way he did in his article. Thats all. Since my own searching did not reveal anything. I wanted to ask here in hopes someone could answer.
Aug 28 '10 #3
Dormilich
8,658 Expert Mod 8TB
not sure about MySQLi, but you can pass an array of parameters directly to PDOStatement->execute(), although this implies the values to be strings (i.e. as type parameter, PDO::PARAM_STR will be passed, regardless whether that is true for the data type or the DB field type)

and to answer the question directly, you can pass your values like the guy in the article, though that requires you to write the appropriate Database Abstraction Layer (classes).
Aug 28 '10 #4
Samishii23
246 100+
Thanks for you time! :)
Aug 28 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: yzzzzz | last post by:
Hi, I am compiling PHP 5.0.2 myself with MySQL support. I did a ./configure --with-mysqli=/usr/local/mysql/bin/mysql_config (see end of post for complete configure) Note: I also have...
26
by: Dodger | last post by:
Okay, background... yes, I am another of those evil, spurned, damnable Perl mongers, but I'm not trying to start a flamewar, I'm juust tryung to understand something... I can write a script in...
2
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar...
12
by: davids58 | last post by:
trying to figure out how to use a mysql database with PHP. I ran the following code: <?php // defines database connection data define('DB_HOST', 'localhost'); define('DB_USER', 'ajaxuser');...
13
by: Schmidty | last post by:
If you do a page reload with $_SERVER will your program lose a mysqli connection upon the reload of the page? Would this code work? I need to know how to carry over a connection between methods as...
7
by: Schmidty | last post by:
Okay...I have another 'newbie' question; I have a function that loads a page and the action is $_SERVER; In the form that is in a function(method?) within a class a variable is passed back to...
21
by: Daz | last post by:
Hi everyone. I am trying to create an extension of the mysqli class within PHP, and I am finding it quite difficult. I am fairly new to PHP classes, and decided to give them a go. Here's what I...
2
by: webcm123 | last post by:
People say that structural programming isn't good for database connection. I code fast-running structural oriented CMS and I don't know what I should do. I use mysql connection using mysql_*. I...
2
by: Michael | last post by:
Hi, I try to use mysqli object instead of standard mysql functions. Is it ok to create mysqli object within my class or schould I pass mysqli object to my object. The problem is, with code...
2
by: Taras_96 | last post by:
Hi everyone, I'm trying to run a number of commands stored within a sql file from within php using mysqli::query. The syntax I'm using is: source C:\data\projects\forum...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.