mysqli

Get autoincrement id after an insert query performed with a prepared statement

If I execute an insert query with a stored procedure with php and the mysqli_* functions, is there a way to retrieve the value of an autoincrement id field? mysqli->insert_id does not seem to work. ...

PHP and "turning on" mysqli

I'm having trouble finding documentation about how exactly to go about "turning on" mysqli. I'm running OS X SL and, as I understand it, since php5 is installed, the mysqli extension should already be there as well. Is this as simple as adding a LoadModule line to php.ini? If I need to re-compile php, does anyone know of a good link...

PHP mysqli reconnect problem

I am having trouble using the mysqli class in PHP and I haven't been able to find the answer anywhere. In my script a class creates a mysqli connection that it uses throughout it's functions. Afterward, this script forks. The connection is used by the children as well, but I'm running into the problem of the connection being closed (MYS...

Help with mysqli_stmt_store_result()

I'm having trouble trying to use $stmt->store_result() after executing a prepared statement. The manual says "Transfers a result set from a prepared statement", but to where? I would ideally like to use it, all nice an buffered in memory, like mysqli->query() returns. The php documentation examples make it seem like the only good reaso...

PHP MySQLi Multiple Inserts

I'm wondering if prepared statements work the same as a normal mysql_query with multiple VALUES. INSERT INTO table (a,b) VALUES ('a','b'), ('c','d'); VS $sql = $db->prepare('INSERT INTO table (a,b) VALUES (?, ?); If I use the prepared statement in a loop, is MySQL optimizing the insert in the background to work like it would in the...

get array of rows with mysqli result

Hi there i'm trying to check if a string match one of the fields in a certain column in a table for this i need to get all the rows from result object i'm using php 5.2.x so can't use fetch_row_all method instead i'm tring to build a new array that will hold all rows here is my code: $sql = new mysqli($config['host'],$config['user'],$co...

Mysqli parameter binding issue

I need an extra set of eyes on this one. Any help will be greatly appreciated. This is a very simple search query, but for whatever reason I cannot find the bug. Well, I know where the bug is. I just can't get past it. Anyway..... I am taking a search value from a POST variable, setting that variable and then setting a column variable a...

SSL Connections with ADODB

I have a project we are about to wrap up, but just got a request from the DBA to make all our connections SSL. So I switched the driver to mysqli in the object that turns out ADODB instances, but I don't see any native method to create secure connections. To make things more difficult, there is a different set of certs and keys per con...

Pear Log MDB2 message length and errors

Hey all, I recently set up a SQL logging framework with PEAR, and everything was working fine. However, I thought that the default length of the message field (VARCHAR 200) was a little short, so I changed my database structure in phpmyadmin to increase this to 512. However, I quickly realized that this changed completely stopped loggi...

insert data to the database, and then get an autogenerated int key in return

Hi. Couldn't find a method like the int executeUpdate(String sql, int autoGeneratedKeys) in php. I want to insert data to the database, and then get an autogenerated int key in return (the ID). Thanks :) Oh, and PS: it has to be a method from the mysqli class =) ...

php mysqli WHERE IN (?,?,? ...)

According to http://us2.php.net/manual/en/mysqli-stmt.bind-param.php, the different types are: i corresponding variable has type integer d corresponding variable has type double s corresponding variable has type string b corresponding variable is a blob and will be sent in packets However, how can you handle this: ->prepare(...

problem saving to mysql database php mysqli

Hi all i'm trying to save data to database and i get an error i never saw before i have a hunch it has something to do with the db collation but I'm not sure whats wrong, here is the query: $query1 = "INSERT INTO scape.url (url,normalizedurl,service,idinservice) VALUES (url, normalizedurl, 4, 45454)"; $query = "INSERT INTO ...

case insensitive search in php

Hello! I use a little search script in my site. After post the search form, i get this variable: $var = $_GET[$q] ; $trimmed = trim($var); Then i try to search in database: $query = "select * from test where acc like \"%$trimmed%\""; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); ....... I try to search...

What's the most efficient driver to use with ADODB to access a MySQL5 Database ?

I've been using ADODB for PHP on several projects for quite some time, and I like it for the ease of use and the efficiency. I've never been too curious about the way that lib accesses data because you know...it just worked :) But today I realized I'm still relying on the legacy MySQL4 ADODB drivers. I'm using MySQL 5.x, and it would pr...

grab current user id - php class

Hello everone, I am buidling a small job application website, and i'm using a the basis of a login system taken from a Nettuts.com tutorial. The logging in works fine, but I am having trouble getting the details for the currently logged in user, for example if a user enters their personal details, i can process the data into the databas...

Are PHP MySQLi prepared queries with bound parameters secure?

Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up touching the database. Now that I've completely converted over to MySQLi and I'm using prepared queries with bound parameters, have I effectively eliminated the possibility of SQL injection attacks? Am I correct in saying I no lon...

PHP, mysqli, and table locks?

I have a database table where I need to pull a row, test user input for a match, then update the row to identify the user that made the match. Should a race condition occur, I need to ensure that the first user's update is not overwritten by another user. To accomplish this I intend to: 1. Read row 2. Lock table 3. Read row again and c...

mysqli - $stmt->num_rows returning 0

Hello everyone, i am looking to count the number of records returned by the query below using mysqli / prepared statements: $mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT id,vcref,jobtitle,jobtype,jobintro,closingdate FROM jobs WHERE...

PHP extending class properties

Hi, I have two classes in a PHP application, B extending A for example. Class A has a function which returns some of its other properties in the form of an array of SQL insert queries eg Class A { $property_a; $property_b; $property_c; $property_d; function queries() { $queries = array(); $queries[] = "INSERT INTO xxx VALUES " . $this-...

What does Apache need to support both mysqli and PDO?

I'm considering changing some PHP code to use PDO for database access instead of mysqli (because the PDO syntax makes more sense to me and is database-agnostic). To do that, I'd need both methods to work while I'm making the changeover. My problem is this: so far, either one or the other method will crash Apache. Right now I'm using XA...