mysql

Prepared statement with PHP and MySQL without using mysqli

Hi, I'd like to know if it is possible to create a prepared statement with PHP and MySQL using the mysql library rather than the mysqli library. I can't find anything on the PHP documentation. Thanks. ...

mysql_fetch_* function does not return any NULL columns in the array

When I call mysql_fetch_row() or mysql_fetch_array(), any column that is NULL is not in the returned array. Is this a feature? Context: I am using CakePHP to get data using Model::find(). EDIT The issue is that when I use the SQL statement: SELECT col_1, col_2 FROM table where col_1 is defined as VARCHAR NOT NULL and col_2 as VARC...

How to simulate more than 1 request(i.e. 4000 or more) on a single page to test performance?

Suppose I have a page called mysql_query_performance.php which contains code to select some records from table and echo it. But I want to know how can I simulate more than 1 request to test the performance of that query? Is this Possible? If yes, How? ...

PHP/PDO - Flush privileges

Hi, I'm doing some mysql server management with a script that flushes the MySQL users privileges when new privileges are added to a MySQL user. I'm using the PDO class to do my queries, but when I do a simple FLUSH PRIVILEGES; I get, for $connection->exec('FLUSH PRIVILEGES;'); and $connection->query('FLUSH PRIVILEGES;'); S...

How can I test that a SQL "CREATE TABLE" statement is equivalent to an existing table?

For each table in my MySQL database I have a mytablename.sql file which contains the CREATE TABLE statement for that table. I want to add a test to check that noone has added/altered a column in the live database without updating this file - that it, I want to check that I can re-create an empty database using these scripts. How can I ...

How I can Get value of nth row from mysql ??

I tried below code $sql=mysql_query("SELECT * FROM `user`"); $result=mysql_result($sql, 6); echo $result; It returns the value of first field of 7th row. But Its works fine till 9th row. And after that it returns again from 1 . So anyone please help .. how I can get value of n-th row from mysql. Thanking You. [email protected]...

Inserting into mysql database with asian symbols such as ’ —

I cant seem to get these Chinese punctuation marks to work with my database (utf-8) when i do an echo of the query the marks look like this ��� in php i have already done $text=mysql_real_escape_string(htmlentities($text)); so as a result they are not saved into the database correctly what can i do to fix this? Thanks ...

Should I index or store these fields in Solr (or any db) ?

Background: I have a cclassifieds website, and users may for example search for cars, and specify a price range, mileage, fueltype, gearbox and a manually inputted query-string if they like to put something specific into the search, ex "bmw m3". Questions: I am about to move this information to Solr for faster lookup, and wonder if I ...

Invalid Jboss Datasources after redeploy

I'm developing an application tha uses seven datasources (ds) for MySql databases. I'm pretty satisfied with the result when it is working. However i'm getting are datasource related problems when I redeploy my aplication. Here is one of the seven ds I've configured in my my-application-ds.xml: <xa-datasource> <jndi-name>jd...

GROUP and COUNT() ages in CakePHP

I'm trying to group by date of birth and count based on the results, using CakePHP. Here's my query. $data = $this->User->find('all', array( 'fields' => array( "DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(User.dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(User.dob, '00-%m-%d')) AS age", 'COUNT(id)' ), ...

Database queries in Java

How can I connect to MySQL db and execute queries ? ...

Filter results in page relating a id-parameter

Hello, I use a SELECT to get all the rows from the table tblnavigation. The rows are: idnav, idnavcat, prognav, progurl $rsnav = mysql_query($query_rsnav, $concat) or die(mysql_error()); $row_rsnav = mysql_fetch_assoc($rsnav); The idnavcat stands for the navigation category. Now i want to filter on that "idnavcat"; and show the resul...

Get domain from URL to GROUP BY using MySQL

I have a table filled with URLs. The URLs are in all sorts of formats: http://foo.com, http://bar.foo.com, http://foo.com/bar, etc. But I'm only interested in the domain name itself, so in this case: foo.com. What I'd like to do is select how many times domain names exists in this table. So something like: SELECT "whatever the domain is...

To connect MySQL Workbench with Aptana Radrails

Hi, I am unable to connect the two. Mainly I can't get the rake function to work. Can anyone offer suggestions? ...

Saving and retrieving blobs using Propel ORM (YML, Propel and PHP question)

I am using Propel (1.4) with Symfony 1.31 (with mySQL db). I want to save save/retriev BLOB (gzipped) data to/from the database My db schema is defined in YML. Suppose the schema looks like this: demo_blobbed_object: _attributes: { phpName: MrBlobby } id: name: {type: varchar(32)} data: {type: ? } I have the following questi...

loading an entire linked list in a single Ruby/MySQL query

I'm storing linked lists of data in records that look like this: CREATE TABLE IF NOT EXISTS `data_nodes` ( `record_id` int(11) NOT NULL, `prev_node` int(11) NOT NULL, `data` varchar(200) NOT NULL, PRIMARY KEY (`record_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; where prev_node is the record_id of the previous item in the list,...

Combining two conditional logic results into one case statement

I have written a query to Select sales values from a database and apply discounts if there were any used. The discounts are either a percentage or just a flat-value. My Query applies the discounts (first case statement) and then pulls the amount that was applied. It got me thinking if it was possible to get this done in one case state...

mysql Select related objects by tags

On a page which shows a specific object I need to display related objects for that object based on tags. ´The object with the most matching tags should be at the top. Basically I somhow need to identify how many tags for each object that match the object on the page and display the top results. My db schema: Table Object ------------ ...

SPSS and PHP/MySQL Integration

I apologize up front for the broadness of this question, but I'm wondering if anyone has any suggestions/pointers. A friend's company uses SPSS for statistical data, surveys, etc. They'd like to be able to slice and dice the the info via a web interface. I have no knowledge of SPSS, so there may be a simple web front end, but being a PH...

How to get number of specific rows from a different table in a subquery

I know it's possible, but I'm not experienced enough to know how to do subqueries. Here's the situation: Table 1: +--------------------+--------------------+ | v_id | v_name | +--------------------+--------------------+ | 1 | v_name1 | +--------------------+--------------------+ | et...