News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen's Blog:
Some notes on SQL Server blobs with sqlsrv
November 22, 2010 @ 11:15:33

In this new post to his blog, Rob Allen has posted notes on some of his experience in working with blobs with SQL Server using UTF-8.

This turned out to be easy enough: Use ntext, nvarchar types in the database and add resources.db.params.driver_options.CharacterSet = "UTF-8" to your application.ini

He also includes some code to fix a problem he spotted with storing binary data into a varbinary field giving him an error about string translation. The fix came in the way of replacing the direct file_get_contents assignment to a variable over to a binding method that specified the data type as well.

0 comments voice your opinion now!
sqlserver binary data insert datatype varbinary


CatsWhoCode.com:
WordPress How to insert data programmatically
August 03, 2010 @ 10:14:02

On the CatsWhoCode.com blog today they share an alternative method for getting content into your WordPress blog - a programmatic approach pushing it directly in through bits of code.

Recently, a client of mine asked me to write an article importer for his WordPress powered site, which was a very interesting project for me. In this article, I'll show you how you can easily add data (posts, comments, categories, etc) to your WordPress blog, without any manual effort.

They describe and show examples for a few different types of inserts:

  • Inserting posts
  • Inserting comments
  • Adding categories to a post
  • Adding tags to a post
  • Automatically create a custom field when a post is published

Code snippets are provided for each.

0 comments voice your opinion now!
wordpress insert data programmatic


Chris Jones' Blog:
Inserting and Updating Oracle XMLType columns in PHP
July 13, 2009 @ 08:14:21

All of you Oracle users out there might want to check out this recent post from Chris Jones, especially if you've been using the XMLType columns in your tables.

Today a reader mailed me about manipulating XMLType columns when the data is longer than the 4K limit that character-type handling imposes. My free book (see sidebar) has examples of how to do this using CLOB handling in PHP. I noticed that my xmlinsert.php example in the book does a SELECT and UPDATE, but never actually does an INSERT.

To correct the problem of the missing example he includes example code to connect to the database, push the XML into a bind variable and select the row back out to ensure everything's still structured correctly. You need to set up a new descriptor for the insert to work (CLOB).

0 comments voice your opinion now!
clob column xmltype xml oracle insert


Eran Galperin's Blog:
Multiple row operations in MySQL / PHP
May 14, 2009 @ 09:35:35

Eran Galperin has made a recent post about performing multiple row operations in MySQL - inserts and updates.

Multiple row operations are in common use in a normalized application databases as one database entity is often linked to multiple sub-entities (for example a user and his tags). [...] Too often I've seen such queries ran in long loops one at a time, which is very bad for performance (as I will show here) and sometimes equally bad for integrity (if the process is interrupted). So what are the alternatives?

His alternatives include concatenation of values for an insert (rather than looping) and updating the information with a "ON DUPLICATE KEY UPDATE" statement or, for multiple tables, using a join.

0 comments voice your opinion now!
tutorial insert update mysql


Rob Allen's Blog:
UTF8, PHP and MySQL
March 19, 2009 @ 08:43:19

Rob Allen had a problem - he needed to get the "pound" (as in the British monetary unit) into his MySQL database. His database didn't seem to want to comply:

Everyone else probably already knows this stuff, but I hit an issue today to that took a while to sort out. Fortunately, some kind folks on IRC helped me, but as it's embarrassing to ask for help on the same issue twice, I'm writing down what I've learned! The problem: Get a £ character stored to MySQL, retrieved and then displayed without any weird characters in front of it using UTF8.

His solution? Make sure you're using UTF-8 everywhere, not just when trying to insert into the database - in the broser's headers (both going in and coming out) and in the MySQL database insert. He gives code examples for each including database examples for PDO and the Zend_Db component of the Zend Framework.

0 comments voice your opinion now!
utf8 mysql insert pound character example problem solution


Johannes Schluter's Blog:
MySQL Storage Engine based on PHP
December 30, 2008 @ 08:42:03

In this new post to his blog Johannes Schluter looks at creating a storage engine plugin for MySQL via its plugin interface.

MySQL 5.1 has a plugin interface to easily add storage engines. PHP can easily embedded into other applications. So why not combine these two things? - Writing a MySQL Storage Engine which reads data by calling a PHP script.

He starts with a basic example with create_table and open_table functions that can pull the data from the table marked with the "Engine" setting of PHP. He expands on this to allow for more functionality - update, delete and write methods are added.

0 comments voice your opinion now!
mysql storage engine table tutorial update insert select delete


DevShed:
Inserting, Updating and Deleting Database Rows with Code Igniter
September 24, 2008 @ 12:03:27

DevShed continues their series focusing on the CodeIgniter framework with the seventh part - a look at interacting with the database to update, delete and insert rows from your application.

You've seen some of the things you can accomplish with the Code Igniter PHP framework in earlier parts of this series. In this seventh part of the series, you will learn, through copious examples, how to perform insertions, updates and deletions on a selected MySQL table by using Code Igniter's database class. You'll see that these tasks are very intuitive and easy to grasp, thanks to Code Igniter's friendly learning curve.

They show how to make conditional select statements (with where clauses) and do both inserts of new information and updates to current information, all with the built-in model functionality the framework provides.

0 comments voice your opinion now!
codeigniter framework tutorial update delete insert conditional


ProDevTips.com:
File Uploads with PHP Doctrine
September 01, 2008 @ 10:37:50

The ProDevTips blog has posted the fifth part of their look at using Doctrine with PHP. This time they focus on file uploads.

It's time to take a look at how file uploads can be integrated into the Doctrine validation and CRUD process. We will have a product in the form of a digital download as an example, it will have a screenshot image that can be maximum 250 pixels wide and high. The download itself will be a zipped file.

They set up their table definitions first and set up a few validation functions (update, insert and for the file data) to work on top of that. Custom upload/uploadImage and save methods handle the user's submission while a simple delete method makes removing images easy.

0 comments voice your opinion now!
file upload doctrine tutorial database table insert image


Raphael Stolt's Blog:
Transforming data centered XML into SQL statements
May 08, 2007 @ 10:27:00

In this new post on Raphael Stolt's blog, he shows a way that you can take XML that holds SQL information (in his example INSERTs and DELETEs) and transforms them into SQL statements via XSL stylesheets.

A canny data import technique that emerged from praxis, while working on the import of data-centered XML resources, is utilitizing the abilities of Xslt. The generation of the required SQL statements actually only needs a simple Xsl stylesheet which might import for an PHP XSLTProcessor object or pass to the xsltproc command line tool. Both further described approaches are based upon the libxslt library and are assuming the use of XSLT 1.0.

He starts with an example bit of XML that has the XSL stylesheet at the top that will be used to transform the data and the information to perform inserts on several "partner" values in the XML below. Following this, he creates a PHP class to load the file and apply the stylesheet.

He also mentions a few different approaches to the same problem - XSLTProcessor class approach returning a single SQL string , xsltproc approach and the XSLTProcessor class approach using the ability to use PHP functions as XSLT functions.

0 comments voice your opinion now!
transform xml sql statement xslt insert delete transform xml sql statement xslt insert delete


DeveloperTutorials.com:
Inserting An Array Into A Database
February 02, 2007 @ 10:28:31

The DeveloperTutorials website has a quick new article today talking about the insertion of an entire array into a database:

A few days ago, a user came into #phphelp on UnderNet wanting to know how to insert an array into a database. A simple enough concept, but how exactly does one look up information on the subject? The goal is to take a form with multiple input sets (like a list of people, their phone numbers, etc.) and input multiple rows into a database.

They create the database and a simple form to get the array input from before sharing the code to grab the information and loop through them all and drop them into the database table.

1 comment voice your opinion now!
insert array database tutorial simple loop insert array database tutorial simple loop



Community Events





Don't see your event here?
Let us know!


community zendserver language release list api framework code introduction voicesoftheelephpant podcast deployment threedevsandamaybe bugfix series laravel symfony interview tips conference

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework